Skip to content

Commit

Permalink
Fix pylint.
Browse files Browse the repository at this point in the history
  • Loading branch information
pattisdr committed Jul 16, 2024
1 parent 412424a commit b27bf03
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/fideslang/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1084,8 +1084,10 @@ def privacy_declarations_reference_data_flows(
Any `PrivacyDeclaration`s which include `egress` and/or `ingress` fields must
only reference the `fides_key`s of defined `DataFlow`s in said field(s).
"""
privacy_declarations = self.privacy_declarations or []
for privacy_declaration in privacy_declarations:
privacy_declarations: List[PrivacyDeclaration] = self.privacy_declarations or []
for (
privacy_declaration
) in privacy_declarations: # pylint:disable=not-an-iterable
for direction in ["egress", "ingress"]:
fides_keys = getattr(privacy_declaration, direction, None)
if fides_keys is not None:
Expand All @@ -1097,7 +1099,8 @@ def privacy_declarations_reference_data_flows(

for fides_key in fides_keys:
assert fides_key in [
data_flow.fides_key for data_flow in data_flows
data_flow.fides_key
for data_flow in data_flows # pylint:disable=not-an-iterable
], f"PrivacyDeclaration '{privacy_declaration.name}' defines {direction} with '{fides_key}' and is applied to the System '{system}', which does not itself define {direction} with that resource."

return self
Expand Down
14 changes: 10 additions & 4 deletions tests/fideslang/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
FidesValidationError,
valid_data_type,
validate_fides_key,
validate_path_of_http_url,
validate_path_of_url,
)
from tests.conftest import assert_error_message_includes

Expand Down Expand Up @@ -828,12 +826,20 @@ def test_system_urls(self):
organization_fides_key="1",
privacy_declarations=[],
system_type="SYSTEM",
privacy_policy="https://justtag.com/PRIVACY_POLICY.pdf",
privacy_policy="https://policy.samsungrs.com/consent/eu/nsc/privacy_policy_de.html",
legitimate_interest_disclosure_url="https://policy.samsungrs.com/consent/eu/nsc/privacy_policy_de.html#gdpr-article",
)

# This is a string and not a Url type, because privacy_policy is using custom type AnyUrlString.
# No trailing slash is added
assert system.privacy_policy == "https://justtag.com/PRIVACY_POLICY.pdf"
assert (
system.privacy_policy
== "https://policy.samsungrs.com/consent/eu/nsc/privacy_policy_de.html"
)
assert (
system.legitimate_interest_disclosure_url
== "https://policy.samsungrs.com/consent/eu/nsc/privacy_policy_de.html#gdpr-article"
)


class TestAnyHttpUrlString:
Expand Down

0 comments on commit b27bf03

Please sign in to comment.