Skip to content

Commit cf26a01

Browse files
committed
style: run 'pre-commit run --all-files'
1 parent f0185f2 commit cf26a01

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+292
-231
lines changed

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#
1111
# All configuration values have a default; values that are commented out
1212
# serve to show the default.
13+
from __future__ import annotations
1314

1415
import datetime
1516
from importlib.metadata import version

docs/user/numpy.ipynb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
"outputs": [],
3434
"source": [
3535
"# Import NumPy\n",
36+
"from __future__ import annotations\n",
37+
"\n",
3638
"import numpy as np\n",
3739
"\n",
3840
"# Import Pint\n",

pint/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from importlib.metadata import version
1717

1818
from .delegates.formatter._format_helpers import formatter
19-
2019
from .errors import ( # noqa: F401
2120
DefinitionSyntaxError,
2221
DimensionalityError,
@@ -31,7 +30,6 @@
3130
from .registry import ApplicationRegistry, LazyRegistry, UnitRegistry
3231
from .util import logger, pi_theorem # noqa: F401
3332

34-
3533
# Default Quantity, Unit and Measurement are the ones
3634
# build in the default registry.
3735
Quantity = UnitRegistry.Quantity

pint/_typing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from __future__ import annotations
22

3-
from typing import TYPE_CHECKING, Any, TypeVar, Union, Protocol
43
from collections.abc import Callable
54
from decimal import Decimal
65
from fractions import Fraction
6+
from typing import TYPE_CHECKING, Any, Protocol, TypeVar, Union
77

8-
from .compat import TypeAlias, Never
8+
from .compat import Never, TypeAlias
99

1010
if TYPE_CHECKING:
1111
from .facets.plain import PlainQuantity as Quantity

pint/compat.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@
1010

1111
from __future__ import annotations
1212

13-
import sys
1413
import math
14+
import sys
15+
from collections.abc import Callable, Iterable, Mapping
1516
from decimal import Decimal
1617
from importlib import import_module
1718
from numbers import Number
18-
from collections.abc import Mapping
1919
from typing import Any, NoReturn
20-
from collections.abc import Callable
21-
from collections.abc import Iterable
2220

2321
try:
2422
from uncertainties import UFloat, ufloat
@@ -190,11 +188,15 @@ def _to_magnitude(value, force_ndarray=False, force_ndarray_like=False):
190188

191189
# Defines Logarithm and Exponential for Logarithmic Converter
192190
if HAS_NUMPY:
193-
from numpy import exp # noqa: F401
194-
from numpy import log # noqa: F401
191+
from numpy import (
192+
exp, # noqa: F401
193+
log, # noqa: F401
194+
)
195195
else:
196-
from math import exp # noqa: F401
197-
from math import log # noqa: F401
196+
from math import (
197+
exp, # noqa: F401
198+
log, # noqa: F401
199+
)
198200

199201
if not HAS_BABEL:
200202
babel_parse = missing_dependency("Babel") # noqa: F811

pint/converters.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@
1212

1313
from dataclasses import dataclass
1414
from dataclasses import fields as dc_fields
15-
1615
from typing import Any, ClassVar
1716

1817
from ._typing import Magnitude
19-
20-
from .compat import HAS_NUMPY, exp, log, Self # noqa: F401
18+
from .compat import HAS_NUMPY, Self, exp, log # noqa: F401
2119

2220

2321
@dataclass(frozen=True)

pint/definitions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
from __future__ import annotations
1212

13-
from . import errors
1413
import flexparser as fp
14+
15+
from . import errors
1516
from .delegates import ParserConfig, txt_defparser
1617

1718

pint/delegates/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
:copyright: 2022 by Pint Authors, see AUTHORS for more details.
88
:license: BSD, see LICENSE for more details.
99
"""
10+
from __future__ import annotations
1011

1112
from . import txt_defparser
1213
from .base_defparser import ParserConfig, build_disk_cache_class

pint/delegates/base_defparser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
from dataclasses import dataclass
1818
from typing import Any
1919

20+
import flexcache as fc
21+
import flexparser as fp
22+
2023
from pint import errors
2124
from pint.facets.plain.definitions import NotNumeric
2225
from pint.util import ParserHelper, UnitsContainer
2326

24-
import flexcache as fc
25-
import flexparser as fp
26-
2727

2828
@dataclass(frozen=True)
2929
class ParserConfig:

pint/delegates/formatter/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
:copyright: 2022 by Pint Authors, see AUTHORS for more details.
1111
:license: BSD, see LICENSE for more details.
1212
"""
13-
13+
from __future__ import annotations
1414

1515
from .full import FullFormatter
1616

pint/delegates/formatter/_format_helpers.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,20 @@
1111

1212
from __future__ import annotations
1313

14+
import locale
15+
from collections.abc import Callable, Generator, Iterable
16+
from contextlib import contextmanager
1417
from functools import partial
18+
from locale import LC_NUMERIC, getlocale, setlocale
1519
from typing import (
16-
Any,
17-
TypeVar,
1820
TYPE_CHECKING,
21+
Any,
1922
Literal,
2023
TypedDict,
24+
TypeVar,
2125
)
22-
from collections.abc import Generator, Iterable, Callable
23-
24-
from locale import getlocale, setlocale, LC_NUMERIC
25-
from contextlib import contextmanager
2626
from warnings import warn
2727

28-
import locale
29-
3028
from pint.delegates.formatter._spec_helpers import FORMATTER, _join
3129

3230
from ...compat import babel_parse, ndarray
@@ -38,9 +36,9 @@
3836
np_integer = None
3937

4038
if TYPE_CHECKING:
41-
from ...registry import UnitRegistry
42-
from ...facets.plain import PlainUnit
4339
from ...compat import Locale, Number
40+
from ...facets.plain import PlainUnit
41+
from ...registry import UnitRegistry
4442

4543
T = TypeVar("T")
4644
U = TypeVar("U")

pint/delegates/formatter/_spec_helpers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010

1111
from __future__ import annotations
1212

13-
from typing import Any
14-
from collections.abc import Iterable, Callable
13+
import re
1514
import warnings
15+
from collections.abc import Callable, Iterable
16+
from typing import Any
17+
1618
from ...compat import Number
17-
import re
1819

1920
FORMATTER = Callable[
2021
[

pint/delegates/formatter/_to_register.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@
88

99
from __future__ import annotations
1010

11-
from typing import TYPE_CHECKING
1211
from collections.abc import Callable
13-
from ...compat import ndarray, np, Unpack
14-
from ._spec_helpers import split_format, join_mu, REGISTERED_FORMATTERS
12+
from typing import TYPE_CHECKING
1513

1614
from ..._typing import Magnitude
17-
18-
from ._format_helpers import format_compound_unit, BabelKwds, override_locale
15+
from ...compat import Unpack, ndarray, np
16+
from ._format_helpers import BabelKwds, format_compound_unit, override_locale
17+
from ._spec_helpers import REGISTERED_FORMATTERS, join_mu, split_format
1918

2019
if TYPE_CHECKING:
21-
from ...facets.plain import PlainQuantity, PlainUnit, MagnitudeT
20+
from ...facets.plain import MagnitudeT, PlainQuantity, PlainUnit
2221
from ...registry import UnitRegistry
2322

2423

pint/delegates/formatter/full.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@
1111

1212
from __future__ import annotations
1313

14-
from typing import TYPE_CHECKING, Literal, Any
15-
from collections.abc import Callable, Iterable
1614
import locale
17-
from ...compat import babel_parse, Number, Unpack
18-
from ...util import iterable
15+
from collections.abc import Callable, Iterable
16+
from typing import TYPE_CHECKING, Any, Literal
1917

2018
from ..._typing import Magnitude
21-
from .html import HTMLFormatter
22-
from .latex import LatexFormatter, SIunitxFormatter
23-
from .plain import RawFormatter, CompactFormatter, PrettyFormatter, DefaultFormatter
19+
from ...compat import Number, Unpack, babel_parse
20+
from ...util import iterable
2421
from ._format_helpers import BabelKwds
2522
from ._to_register import REGISTERED_FORMATTERS
23+
from .html import HTMLFormatter
24+
from .latex import LatexFormatter, SIunitxFormatter
25+
from .plain import CompactFormatter, DefaultFormatter, PrettyFormatter, RawFormatter
2626

2727
if TYPE_CHECKING:
28+
from ...compat import Locale
29+
from ...facets.measurement import Measurement
2830
from ...facets.plain import (
2931
GenericPlainRegistry,
32+
MagnitudeT,
3033
PlainQuantity,
3134
PlainUnit,
32-
MagnitudeT,
3335
)
34-
from ...facets.measurement import Measurement
35-
from ...compat import Locale
3636

3737

3838
class FullFormatter:

pint/delegates/formatter/html.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@
1111

1212
from __future__ import annotations
1313

14-
from typing import TYPE_CHECKING
1514
import re
15+
from typing import TYPE_CHECKING
16+
17+
from ..._typing import Magnitude
18+
from ...compat import Unpack, ndarray, np
1619
from ...util import iterable
17-
from ...compat import ndarray, np, Unpack
20+
from ._format_helpers import BabelKwds, format_compound_unit, formatter, override_locale
1821
from ._spec_helpers import (
19-
split_format,
2022
join_mu,
2123
join_unc,
2224
remove_custom_flags,
25+
split_format,
2326
)
2427

25-
from ..._typing import Magnitude
26-
from ._format_helpers import BabelKwds, format_compound_unit, formatter, override_locale
27-
2828
if TYPE_CHECKING:
29-
from ...facets.plain import PlainQuantity, PlainUnit, MagnitudeT
3029
from ...facets.measurement import Measurement
30+
from ...facets.plain import MagnitudeT, PlainQuantity, PlainUnit
3131

3232
_EXP_PATTERN = re.compile(r"([0-9]\.?[0-9]*)e(-?)\+?0*([0-9]+)")
3333

pint/delegates/formatter/latex.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,28 @@
1212

1313

1414
from __future__ import annotations
15-
import functools
16-
17-
from typing import TYPE_CHECKING, Any
18-
from collections.abc import Iterable
1915

16+
import functools
2017
import re
21-
from ._spec_helpers import split_format, FORMATTER
18+
from collections.abc import Iterable
19+
from typing import TYPE_CHECKING, Any
2220

2321
from ..._typing import Magnitude
24-
from ...compat import ndarray, Unpack, Number
25-
from ._format_helpers import BabelKwds, formatter, override_locale, format_compound_unit
26-
from ._spec_helpers import join_mu, join_unc, remove_custom_flags
22+
from ...compat import Number, Unpack, ndarray
23+
from ._format_helpers import BabelKwds, format_compound_unit, formatter, override_locale
24+
from ._spec_helpers import (
25+
FORMATTER,
26+
join_mu,
27+
join_unc,
28+
remove_custom_flags,
29+
split_format,
30+
)
2731

2832
if TYPE_CHECKING:
29-
from ...facets.plain import PlainQuantity, PlainUnit, MagnitudeT
3033
from ...facets.measurement import Measurement
31-
from ...util import ItMatrix
34+
from ...facets.plain import MagnitudeT, PlainQuantity, PlainUnit
3235
from ...registry import UnitRegistry
36+
from ...util import ItMatrix
3337

3438

3539
def vector_to_latex(

pint/delegates/formatter/plain.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,23 @@
1414

1515
from __future__ import annotations
1616

17-
from typing import TYPE_CHECKING
1817
import re
19-
from ...compat import ndarray, np, Unpack
18+
from typing import TYPE_CHECKING
19+
20+
from ..._typing import Magnitude
21+
from ...compat import Unpack, ndarray, np
22+
from ._format_helpers import BabelKwds, format_compound_unit, formatter, override_locale
2023
from ._spec_helpers import (
21-
pretty_fmt_exponent,
22-
split_format,
2324
join_mu,
2425
join_unc,
26+
pretty_fmt_exponent,
2527
remove_custom_flags,
28+
split_format,
2629
)
2730

28-
from ..._typing import Magnitude
29-
30-
from ._format_helpers import format_compound_unit, BabelKwds, formatter, override_locale
31-
3231
if TYPE_CHECKING:
33-
from ...facets.plain import PlainQuantity, PlainUnit, MagnitudeT
3432
from ...facets.measurement import Measurement
33+
from ...facets.plain import MagnitudeT, PlainQuantity, PlainUnit
3534

3635

3736
_EXP_PATTERN = re.compile(r"([0-9]\.?[0-9]*)e(-?)\+?0*([0-9]+)")

pint/delegates/txt_defparser/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
:copyright: 2022 by Pint Authors, see AUTHORS for more details.
88
:license: BSD, see LICENSE for more details.
99
"""
10-
10+
from __future__ import annotations
1111

1212
from .defparser import DefParser
1313

pint/delegates/txt_defparser/block.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
from __future__ import annotations
1717

1818
from dataclasses import dataclass
19-
2019
from typing import Generic, TypeVar
2120

22-
from ..base_defparser import PintParsedStatement, ParserConfig
2321
import flexparser as fp
2422

23+
from ..base_defparser import ParserConfig, PintParsedStatement
24+
2525

2626
@dataclass(frozen=True)
2727
class EndDirectiveBlock(PintParsedStatement):

0 commit comments

Comments
 (0)