Skip to content

Commit 102eec4

Browse files
committed
Fixes due to new Python version
1 parent 2179c15 commit 102eec4

8 files changed

Lines changed: 37 additions & 7 deletions

File tree

code/commands/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import xsdata_hack

code/commands/bibtools/sources/arxiv/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class ArxivEntry:
5151

5252
primary_category: ArxivCategory = field(metadata=dict(type='Element', required=True, namespace=ARXIV_NAMESPACE))
5353
comment: str | None = field(metadata=dict(type='Element', namespace=ARXIV_NAMESPACE), default=None)
54-
affiliation: str | None = field(metadata=dict(type='Element', namespace=ARXIV_NAMESPACE), default=None)
54+
affiliation: str | None = field(metadata=dict(type='Element', namespace=ARXIV_NAMESPACE), default=None)
5555
journal_ref: str | None = field(metadata=dict(type='Element', namespace=ARXIV_NAMESPACE), default=None)
5656
doi: str | None = field(metadata=dict(type='Element', namespace=ARXIV_NAMESPACE), default=None)
5757

code/commands/bibtools/sources/common/keywords.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import warnings
12
from collections.abc import Sequence
23

34
import many_stop_words
@@ -16,7 +17,9 @@ def get_stop_words(language: str) -> Sequence[str]:
1617
lang_code = 'kr'
1718

1819
if lang_code in many_stop_words.available_languages:
19-
return many_stop_words.get_stop_words(lang_code)
20+
with warnings.catch_warnings():
21+
warnings.simplefilter('ignore')
22+
return many_stop_words.get_stop_words(lang_code)
2023

2124
if language in stop_words.AVAILABLE_LANGUAGES:
2225
return stop_words.get_stop_words(language)

code/commands/xsdata_hack.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from typing import Any, get_type_hints
2+
3+
from xsdata.exceptions import XmlContextError
4+
from xsdata.formats.dataclass.models.builders import XmlMetaBuilder
5+
6+
7+
# TODO: Remove when this gets fixed upstream
8+
def find_declared_class_patched(cls: type, clazz: type, name: str) -> Any: # noqa: ARG001,ANN401
9+
"""Find the user class that matches the name.
10+
11+
Todo: Honestly I have no idea why we needed this.
12+
"""
13+
for base in clazz.__mro__:
14+
# ann = base.__dict__.get("__annotations__")
15+
ann = get_type_hints(base) # Only this line is modified
16+
17+
if ann and name in ann:
18+
return base
19+
20+
raise XmlContextError(f'Failed to detect the declared class for field {name}')
21+
22+
23+
24+
setattr(XmlMetaBuilder, 'find_declared_class', classmethod(find_declared_class_patched)) # noqa: B010

code/notebook/bibtex/entry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from collections.abc import Collection, Iterable, Mapping, Sequence
2-
from dataclasses import dataclass, field, asdict
2+
from dataclasses import asdict, dataclass, field
33
from typing import Annotated, Literal, get_args, get_type_hints
44

55
from ..support.iteration import string_accumulator

code/notebook/math/logic/derivation/minimal_implicational_logic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def introduce_conclusion_hypothesis(system: AxiomaticDerivationSystem, derivatio
3434
if len(derivation.payload) == 0:
3535
return derivation
3636

37-
*rest, conclusion = derivation.payload
37+
*_rest, conclusion = derivation.payload
3838

3939
goal = ConnectiveFormula(BinaryConnective.CONDITIONAL, hypothesis, conclusion)
4040

code/ruff.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ ignore = [
3535
"EM",
3636
"ERA001",
3737
"FA100", "FA102",
38+
"FIX",
3839
"FURB129",
3940
"G004",
4041
"NPY",
@@ -46,11 +47,12 @@ ignore = [
4647
"PTH123",
4748
"PYI025", "PYI041",
4849
"RET504",
49-
"TC001",
5050
"RUF001", "RUF003", "RUF018",
5151
"S101", "S105", "S311", "S314", "S324", "S310", "S603",
5252
"SIM108", "SIM118", "SIM910",
53+
"TC001",
5354
"TC002", "TC003", "TC006",
55+
"TD",
5456
"TID252",
5557
"TRY003",
5658
"UP031",

figures/ex__def__logistic_map__orbits.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import tempfile
44
import os
55
import shutil
6-
from concurrent.futures import ProcessPoolExecutor
6+
from concurrent.futures import ThreadPoolExecutor
77
from textwrap import dedent
88

99
import numpy as np
@@ -46,7 +46,7 @@ def fill_pixels(j: int):
4646
return column
4747

4848

49-
with ProcessPoolExecutor() as executor:
49+
with ThreadPoolExecutor() as executor:
5050
columns = list(executor.map(fill_pixels, list(range(a_resolution))))
5151

5252

0 commit comments

Comments
 (0)