Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dataclass(frozen=True) for compatibility with Python 3.13 (incomplete, needs help) #2037

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -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)
-----------------
Expand Down
24 changes: 12 additions & 12 deletions pint/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand All @@ -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."""

Expand All @@ -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."""

Expand All @@ -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."""

Expand All @@ -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."""

Expand All @@ -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."""

Expand All @@ -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."""

Expand All @@ -233,21 +233,21 @@ 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

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

Expand Down
Loading