diff --git a/src/fideslang/default_fixtures.py b/src/fideslang/default_fixtures.py index 9838a83..c8f9a4b 100644 --- a/src/fideslang/default_fixtures.py +++ b/src/fideslang/default_fixtures.py @@ -9,7 +9,6 @@ 2. Copy/Paste the JSON response below """ - COUNTRY_CODES = [ {"name": "Afghanistan", "alpha3Code": "AFG"}, {"name": "Ă…land Islands", "alpha3Code": "ALA"}, diff --git a/src/fideslang/default_taxonomy/__init__.py b/src/fideslang/default_taxonomy/__init__.py index b032904..6b16070 100644 --- a/src/fideslang/default_taxonomy/__init__.py +++ b/src/fideslang/default_taxonomy/__init__.py @@ -7,8 +7,8 @@ from .data_uses import DEFAULT_DATA_USES from .organizations import DEFAULT_ORGANIZATIONS -sort_data_types = ( - lambda x: x.parent_key if hasattr(x, "parent_key") and x.parent_key else x.fides_key +sort_data_types = lambda x: ( + x.parent_key if hasattr(x, "parent_key") and x.parent_key else x.fides_key ) DEFAULT_TAXONOMY = Taxonomy( diff --git a/src/fideslang/manifests.py b/src/fideslang/manifests.py index 60143a0..8868ffc 100644 --- a/src/fideslang/manifests.py +++ b/src/fideslang/manifests.py @@ -1,4 +1,5 @@ """This module handles anything related to working with raw manifest files.""" + import glob from functools import reduce from typing import Dict, List, Set, Union diff --git a/src/fideslang/models.py b/src/fideslang/models.py index 03e2979..2310dfa 100644 --- a/src/fideslang/models.py +++ b/src/fideslang/models.py @@ -470,7 +470,7 @@ def valid_meta(cls, meta_values: Optional[FidesMeta]) -> Optional[FidesMeta]: "The 'return_all_elements' attribute can only be specified on array fields." ) return meta_values - + @model_validator(mode="after") def validate_object_fields( self, @@ -493,6 +493,8 @@ def validate_object_fields( f"The data type '{data_type}' on field '{field_name}' is not compatible with specified sub-fields. Convert to an 'object' field." ) + return self + # this is required for the recursive reference in the pydantic model: DatasetField.model_rebuild() diff --git a/src/fideslang/parse.py b/src/fideslang/parse.py index 9c1a25c..27d04fd 100644 --- a/src/fideslang/parse.py +++ b/src/fideslang/parse.py @@ -2,6 +2,7 @@ This module handles everything related to parsing resources into Pydantic models, either from local files or the server. """ + from typing import Dict, List from fideslang import FidesModel, Taxonomy, model_map diff --git a/src/fideslang/validation.py b/src/fideslang/validation.py index 9c1639c..74c3c46 100644 --- a/src/fideslang/validation.py +++ b/src/fideslang/validation.py @@ -1,6 +1,7 @@ """ Contains all of the additional validation for the resource models. """ + import re from collections import Counter from typing import Annotated, Dict, List, Optional, Pattern, Set, Tuple diff --git a/tests/fideslang/test_validation.py b/tests/fideslang/test_validation.py index 21f3174..f7fe122 100644 --- a/tests/fideslang/test_validation.py +++ b/tests/fideslang/test_validation.py @@ -717,21 +717,26 @@ def test_return_all_elements_on_array_field(self): ) def test_data_categories_at_object_level(self): - # Data categories at the object level ARE allowed now - DatasetField( + + field = DatasetField( name="test_field", data_categories=["user"], fides_meta=FidesMeta( references=None, - identity=None, + identify=None, primary_key=False, data_type="object", length=None, return_all_elements=None, read_only=None, - ) + ), + fields=[DatasetField(name="nested_field")], ) + assert field + assert field.data_categories == ["user"] + assert field.fides_meta.data_type == "object" + def test_data_categories_on_nested_fields(self): field = DatasetField( @@ -756,17 +761,15 @@ def test_data_categories_on_nested_fields(self): primary_key=False, data_type="string", length=None, - return_all_elements=None, read_only=None, + data_categories=["user"], ), ) ], ) assert field - assert field.fields - print(f"fields: {field.fields}") - print(f"field: {vars(field)}") + assert field.data_categories == ["user"] assert field.fields[0].data_categories == ["user"]