Skip to content

Commit

Permalink
chore: bump relaton version (#348)
Browse files Browse the repository at this point in the history
* chore: remove data normalization to reflect model implementation change

* chore: bump relaton version (v0.2.26)

* tests: refactor fixtures to reflect schema changes

* style: add indentation

* chore: upgrade relaton-py version

* fix: mypy

* chore: upgrade mypy version
  • Loading branch information
stefanomunarini authored Dec 20, 2023
1 parent 31dc5f2 commit 430bd36
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 0 additions & 17 deletions bib_models/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion main/tests/test_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ pydantic>=1.10,<2.0
crossrefapi>=1.5,<2
simplejson
sentry-sdk
relaton==0.2.25
relaton==0.2.32
63 changes: 26 additions & 37 deletions xml2rfc_compat/fixtures/test_refdata.json
Original file line number Diff line number Diff line change
Expand Up @@ -705,14 +705,14 @@
],
"person": {
"name": {
"initial": [
{
"given": {
"formatted_initials": {
"content": "R.",
"language": [
"en"
]
}
],
},
"surname": {
"content": "Moskowitz",
"language": [
Expand All @@ -734,14 +734,14 @@
],
"person": {
"name": {
"initial": [
{
"given": {
"formatted_initials": {
"content": "T.",
"language": [
"en"
]
}
],
},
"surname": {
"content": "Heer",
"language": [
Expand All @@ -763,14 +763,14 @@
],
"person": {
"name": {
"initial": [
{
"given": {
"formatted_initials": {
"content": "P.",
"language": [
"en"
]
}
],
},
"surname": {
"content": "Jokela",
"language": [
Expand All @@ -792,14 +792,14 @@
],
"person": {
"name": {
"initial": [
{
"content": "T.",
"language": [
"en"
]
"given": {
"formatted_initials": {
"content": "T.",
"language": [
"en"
]
}
],
},
"surname": {
"content": "Henderson",
"language": [
Expand Down Expand Up @@ -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": [
Expand Down
1 change: 1 addition & 0 deletions xml2rfc_compat/serializers/authors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion xml2rfc_compat/serializers/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
])
Expand Down

0 comments on commit 430bd36

Please sign in to comment.