From 280b037ffeb0017035998c5fe6796edc6e273a30 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Fri, 12 Jul 2024 17:22:15 -0700 Subject: [PATCH 1/3] Test on Python 3.13-dev --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 981f49e0c..c3b7af6d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13-dev"] numpy: [null, "numpy>=1.23,<2.0.0", "numpy>=2.0.0rc1"] uncertainties: [null, "uncertainties==3.1.6", "uncertainties>=3.1.6,<4.0.0"] extras: [null] @@ -104,7 +104,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.10", "3.11", "3.12"] + python-version: ["3.10", "3.11", "3.12", "3.13-dev"] numpy: [ "numpy>=1.23,<2.0.0" ] runs-on: windows-latest @@ -165,7 +165,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.10", "3.11", "3.12"] + python-version: ["3.10", "3.11", "3.12", "3.13-dev"] numpy: [null, "numpy>=1.23,<2.0.0" ] runs-on: macos-latest From 4b34753960979395b304c0f9a290abfc6132c06f Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Fri, 12 Jul 2024 17:23:21 -0700 Subject: [PATCH 2/3] @dataclass(frozen=True) for Python 3.13 compatibility --- pint/errors.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pint/errors.py b/pint/errors.py index 59d3b4569..f080f529d 100644 --- a/pint/errors.py +++ b/pint/errors.py @@ -81,12 +81,12 @@ def def_err(self, msg: str): return DefinitionError(self.name, self.__class__, msg) -@dataclass(frozen=False) +@dataclass(frozen=True) class PintError(Exception): """Base exception for all Pint errors.""" -@dataclass(frozen=False) +@dataclass(frozen=True) class DefinitionError(ValueError, PintError): """Raised when a definition is not properly constructed.""" @@ -102,7 +102,7 @@ def __reduce__(self): return self.__class__, tuple(getattr(self, f.name) for f in fields(self)) -@dataclass(frozen=False) +@dataclass(frozen=True) class DefinitionSyntaxError(ValueError, PintError): """Raised when a textual definition has a syntax error.""" @@ -115,7 +115,7 @@ def __reduce__(self): return self.__class__, tuple(getattr(self, f.name) for f in fields(self)) -@dataclass(frozen=False) +@dataclass(frozen=True) class RedefinitionError(ValueError, PintError): """Raised when a unit or prefix is redefined.""" @@ -130,7 +130,7 @@ def __reduce__(self): return self.__class__, tuple(getattr(self, f.name) for f in fields(self)) -@dataclass(frozen=False) +@dataclass(frozen=True) class UndefinedUnitError(AttributeError, PintError): """Raised when the units are not defined in the unit registry.""" @@ -150,13 +150,13 @@ def __reduce__(self): return self.__class__, tuple(getattr(self, f.name) for f in fields(self)) -@dataclass(frozen=False) +@dataclass(frozen=True) class PintTypeError(TypeError, PintError): def __reduce__(self): return self.__class__, tuple(getattr(self, f.name) for f in fields(self)) -@dataclass(frozen=False) +@dataclass(frozen=True) class DimensionalityError(PintTypeError): """Raised when trying to convert between incompatible units.""" @@ -183,7 +183,7 @@ def __reduce__(self): return self.__class__, tuple(getattr(self, f.name) for f in fields(self)) -@dataclass(frozen=False) +@dataclass(frozen=True) class OffsetUnitCalculusError(PintTypeError): """Raised on ambiguous operations with offset units.""" @@ -208,7 +208,7 @@ def __reduce__(self): return self.__class__, tuple(getattr(self, f.name) for f in fields(self)) -@dataclass(frozen=False) +@dataclass(frozen=True) class LogarithmicUnitCalculusError(PintTypeError): """Raised on inappropriate operations with logarithmic units.""" @@ -233,7 +233,7 @@ def __reduce__(self): return self.__class__, tuple(getattr(self, f.name) for f in fields(self)) -@dataclass(frozen=False) +@dataclass(frozen=True) class UnitStrippedWarning(UserWarning, PintError): msg: str @@ -241,13 +241,13 @@ def __reduce__(self): return self.__class__, tuple(getattr(self, f.name) for f in fields(self)) -@dataclass(frozen=False) +@dataclass(frozen=True) class UnexpectedScaleInContainer(Exception): def __reduce__(self): return self.__class__, tuple(getattr(self, f.name) for f in fields(self)) -@dataclass(frozen=False) +@dataclass(frozen=True) class UndefinedBehavior(UserWarning, PintError): msg: str From 01ea9943ed2111e65d34b3bea3d86528fdd8adc4 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Fri, 12 Jul 2024 17:28:42 -0700 Subject: [PATCH 3/3] Changelog entry --- CHANGES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 5ee199f2c..7211e0224 100644 --- a/CHANGES +++ b/CHANGES @@ -9,7 +9,7 @@ Pint Changelog - Added ℓ as alternative for liter - Fix the default behaviour for pint-convert (cli) for importing uncertainties package (PR #2032, Issue #2016) - Support permille units and `‰` symbol (PR #2033, Issue #1963) - +- Fixed compatibility with Python 3.13 (Issue #1969) 0.24.1 (2024-06-24) -----------------