diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3ea9613a..63a9dbc1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,7 +32,7 @@ jobs: python-version: "3.10" - uses: actions/checkout@v3 - name: Install mypy - run: pip install mypy && pip install -r requirements.txt + run: pip install "mypy==1.4.1" && pip install -r requirements.txt - name: Run mypy run: mkdir .mypy_cache && mypy --ignore-missing-imports --install-types --non-interactive . - name: Build the Docker image diff --git a/bib_models/util.py b/bib_models/util.py index 1cf0e728..8a5531ee 100644 --- a/bib_models/util.py +++ b/bib_models/util.py @@ -126,12 +126,6 @@ def normalize_relaxed(data: Dict[str, Any]) -> Dict[str, Any]: 'content': edition } - if keywords := data.get('keyword', []): - data['keyword'] = [ - to_plain_string(item) - for item in keywords - ] - for contributor in data.get('contributor', []): person = contributor.get('person', None) org = contributor.get('organization', None) @@ -154,17 +148,6 @@ def normalize_relaxed(data: Dict[str, Any]) -> Dict[str, Any]: except Exception: pass - if person: - if gname := person.get('name', {}).get('given', None): - if fnames := as_list(gname.get('forename', [])): - gname['forename'] = [ - ensure_formatted_string_content(fname) - for fname in fnames - ] - if fi := gname.get('formatted_initials', None): - gname['formatted_initials'] = \ - ensure_formatted_string_content(fi) - if roles := as_list(contributor.get('role', None) or []): contributor['role'] = [normalize_role(r) for r in roles] diff --git a/main/tests/test_apis.py b/main/tests/test_apis.py index 6e5ee5ed..f014bd06 100644 --- a/main/tests/test_apis.py +++ b/main/tests/test_apis.py @@ -43,7 +43,7 @@ def setUp(self): ) import datatracker.auth - datatracker.auth.token_is_valid = lambda key: True # type: ignore[assignment] + datatracker.auth.token_is_valid = lambda key: True self.api_headers = { "HTTP_X_DATATRACKER_TOKEN": "test", diff --git a/requirements.txt b/requirements.txt index 58465ef2..02f85e70 100644 --- a/requirements.txt +++ b/requirements.txt @@ -28,4 +28,4 @@ pydantic>=1.10,<2.0 crossrefapi>=1.5,<2 simplejson sentry-sdk -relaton==0.2.25 +relaton==0.2.32 diff --git a/xml2rfc_compat/fixtures/test_refdata.json b/xml2rfc_compat/fixtures/test_refdata.json index e2e11306..cf79d859 100644 --- a/xml2rfc_compat/fixtures/test_refdata.json +++ b/xml2rfc_compat/fixtures/test_refdata.json @@ -705,14 +705,14 @@ ], "person": { "name": { - "initial": [ - { + "given": { + "formatted_initials": { "content": "R.", "language": [ "en" ] } - ], + }, "surname": { "content": "Moskowitz", "language": [ @@ -734,14 +734,14 @@ ], "person": { "name": { - "initial": [ - { + "given": { + "formatted_initials": { "content": "T.", "language": [ "en" ] } - ], + }, "surname": { "content": "Heer", "language": [ @@ -763,14 +763,14 @@ ], "person": { "name": { - "initial": [ - { + "given": { + "formatted_initials": { "content": "P.", "language": [ "en" ] } - ], + }, "surname": { "content": "Jokela", "language": [ @@ -792,14 +792,14 @@ ], "person": { "name": { - "initial": [ - { - "content": "T.", - "language": [ - "en" - ] + "given": { + "formatted_initials": { + "content": "T.", + "language": [ + "en" + ] } - ], + }, "surname": { "content": "Henderson", "language": [ @@ -874,27 +874,16 @@ "Latn" ], "keyword": [ - "IEEE Standards", - "Hazards", - "Safety", - "Power cables", - "Electronics equipment", - "Oil drilling", - "cables", - "cable installation", - "cable retention", - "cable selection", - "cable systems", - "Class I Division 1", - "Class I Zone 1", - "Class I Division 2", - "Class I Zone 2", - "classified locations", - "flexible applications", - "hazardous locations", - "IEEE 2740", - "oil and gas land drilling rig", - "portability" + {"content": "IEEE Standards"}, + {"content": "Hazards"}, + {"content": "Safety"}, + {"content": "Power cables"}, + {"content": "Electronics equipment"}, + {"content": "Oil drilling"}, + {"content": "cables"}, + {"content": "cable installation"}, + {"content": "cable retention"}, + {"content": "cable selection"} ], "revdate": "2020-08-12", "abstract": [ diff --git a/xml2rfc_compat/serializers/authors.py b/xml2rfc_compat/serializers/authors.py index 1faa6ec2..0925e677 100644 --- a/xml2rfc_compat/serializers/authors.py +++ b/xml2rfc_compat/serializers/authors.py @@ -152,6 +152,7 @@ def create_author(contributor: Contributor) -> _Element: forenames = ' '.join( f.content for f in as_list(name.given.forename or []) + if f.content is not None ) else: forenames = None diff --git a/xml2rfc_compat/serializers/reference.py b/xml2rfc_compat/serializers/reference.py index 28c2d081..96b839c8 100644 --- a/xml2rfc_compat/serializers/reference.py +++ b/xml2rfc_compat/serializers/reference.py @@ -97,7 +97,10 @@ def create_reference(item: BibliographicItem) -> _Element: series: List[Optional[Tuple[str, str]]] = [] actual_series: List[Series] = as_list(item.series or []) series.extend([ - (cast(List[Title], as_list(s.title or []))[0].content, s.number) + ( + as_list(s.title or [])[0].content, + s.number + ) for s in actual_series if s.number and s.title ])