Skip to content
Snippets Groups Projects

Add and fix more type hints

1 file
+ 12
2
Compare changes
  • Side-by-side
  • Inline
@@ -183,6 +183,7 @@ class Entity:
Special attributes, as defined by the global variable SPECIAL_ATTRIBUTES and additionaly
the "value" are copied using setattr.
"""
new: Union[File, Property, RecordType, Record, Entity]
if self.role == "File":
new = File()
elif self.role == "Property":
@@ -462,6 +463,8 @@ class Entity:
def revoke_denial(self, realm=None, username=None,
role=None, permission=None, priority=False):
if self.acl is None:
raise EntityHasNoAclError("This entity does not have an ACL (yet).")
self.acl.revoke_denial(
realm=realm,
username=username,
@@ -471,6 +474,8 @@ class Entity:
def revoke_grant(self, realm=None, username=None,
role=None, permission=None, priority=False):
if self.acl is None:
raise EntityHasNoAclError("This entity does not have an ACL (yet).")
self.acl.revoke_grant(
realm=realm,
username=username,
@@ -1464,6 +1469,8 @@ out: List[Entity]
raise TransactionError(ae)
else:
e = Container().retrieve(query=self.id, sync=False)[0]
if self.acl is None:
raise EntityHasNoAclError("This entity does not have an ACL yet. Please set one first.")
e.acl = ACL(self.acl.to_xml())
e.update()
@@ -2443,6 +2450,7 @@ class _Properties(list):
return self
def to_xml(self, add_to_element: etree._Element, add_properties: INHERITANCE):
p: Property
for p in self:
importance = self._importance.get(p)
@@ -3581,7 +3589,8 @@ class Container(list):
if is_list_datatype(prop_dt):
ref_name = get_list_datatype(prop_dt)
try:
is_being_referenced.add(container.get_entity_by_name(ref_name).id) # type: ignore
is_being_referenced.add(
container.get_entity_by_name(ref_name).id) # type: ignore
except KeyError:
pass
elif isinstance(prop_dt, str):
@@ -4759,7 +4768,8 @@ class Query():
next_page = self._query_request(query_dict)
etag = next_page.query.etag
if etag is not None and etag != self.etag:
raise PagingConsistencyError("The database state changed while retrieving the pages")
raise PagingConsistencyError(
"The database state changed while retrieving the pages")
yield next_page
index += page_length
Loading