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

RFC: enable flake8-type-checking ruleset #4974

Merged
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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ select = [
"C4", # flake8-comprehensions
"B", # flake8-bugbear
"G", # flake8-logging-format
"TCH", # flake8-type-checking
"YTT", # flake8-2020
"UP", # pyupgrade
"I", # isort
Expand Down
6 changes: 4 additions & 2 deletions yt/data_objects/static_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
from functools import cached_property
from importlib.util import find_spec
from stat import ST_CTIME
from typing import Any, Literal, Optional, Union
from typing import TYPE_CHECKING, Any, Literal, Optional, Union

import numpy as np
import unyt as un
from more_itertools import unzip
from sympy import Symbol
from unyt import Unit, UnitSystem, unyt_quantity
from unyt.exceptions import UnitConversionError, UnitParseError

Expand Down Expand Up @@ -75,6 +74,9 @@
from yt.utilities.parallel_tools.parallel_analysis_interface import parallel_root_only
from yt.utilities.parameter_file_storage import NoParameterShelf, ParameterFileStore

if TYPE_CHECKING:
from sympy import Symbol

if sys.version_info >= (3, 11):
from typing import assert_never
else:
Expand Down
6 changes: 4 additions & 2 deletions yt/frontends/ramses/io.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
from collections import defaultdict
from functools import lru_cache
from typing import Union
from typing import TYPE_CHECKING, Union

import numpy as np

Expand All @@ -17,6 +16,9 @@
from yt.utilities.logger import ytLogger as mylog
from yt.utilities.physical_ratios import cm_per_km, cm_per_mpc

if TYPE_CHECKING:
import os


def convert_ramses_ages(ds, conformal_ages):
issue_deprecation_warning(
Expand Down
2 changes: 1 addition & 1 deletion yt/visualization/fixed_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def __init__(
# the filter methods for the present class are defined only when
# fixed_resolution_filters is imported, so we need to guarantee
# that it happens no later than instantiation
from yt.visualization.fixed_resolution_filters import (
from yt.visualization.fixed_resolution_filters import ( # noqa
FixedResolutionBufferFilter,
)

Expand Down
6 changes: 4 additions & 2 deletions yt/visualization/plot_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
from collections import defaultdict
from numbers import Number
from typing import Optional, Union
from typing import TYPE_CHECKING, Optional, Union

import matplotlib
import numpy as np
Expand Down Expand Up @@ -55,6 +55,9 @@
invalidate_plot,
)

if TYPE_CHECKING:
from yt.visualization.plot_modifications import PlotCallback

if sys.version_info < (3, 10):
from yt._maintenance.backports import zip

Expand Down Expand Up @@ -866,7 +869,6 @@ def __init__(self, *args, **kwargs) -> None:
# the filter methods for the present class are defined only when
# fixed_resolution_filters is imported, so we need to guarantee
# that it happens no later than instantiation
from yt.visualization.plot_modifications import PlotCallback

self._callbacks: list[PlotCallback] = []

Expand Down
8 changes: 6 additions & 2 deletions yt/visualization/profile_plotter.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import base64
import os
from collections.abc import Iterable
from functools import wraps
from typing import Any, Optional, Union
from typing import TYPE_CHECKING, Any, Optional, Union

import matplotlib
import numpy as np
Expand All @@ -28,6 +27,11 @@
validate_plot,
)

if TYPE_CHECKING:
from collections.abc import Iterable

from yt._typing import FieldKey


def invalidate_profile(f):
@wraps(f)
Expand Down
Loading