Skip to content

Commit

Permalink
TYP: use yt._typing explicit type annotations more extensively
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Dec 5, 2022
1 parent df074d8 commit 08c6866
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions yt/data_objects/static_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from unyt.exceptions import UnitConversionError, UnitParseError

from yt._maintenance.deprecation import issue_deprecation_warning
from yt._typing import AnyFieldKey, FieldType, ParticleType
from yt._typing import AnyFieldKey, FieldKey, FieldType, ImplicitFieldKey, ParticleType
from yt.config import ytcfg
from yt.data_objects.particle_filters import ParticleFilter, filter_registry
from yt.data_objects.region_expression import RegionExpression
Expand Down Expand Up @@ -147,9 +147,7 @@ class Dataset(abc.ABC):
default_fluid_type = "gas"
default_field = ("gas", "density")
fluid_types: Tuple[FieldType, ...] = ("gas", "deposit", "index")
particle_types: Tuple[ParticleType, ...] = (
"io",
) # By default we have an 'all'
particle_types: Tuple[ParticleType, ...] = ("io",) # By default we have an 'all'
particle_types_raw: Optional[Tuple[ParticleType, ...]] = ("io",)
geometry = "cartesian"
coordinates = None
Expand All @@ -166,7 +164,7 @@ class Dataset(abc.ABC):
_particle_type_counts = None
_proj_type = "quad_proj"
_ionization_label_format = "roman_numeral"
_determined_fields: Optional[Dict[str, List[Tuple[str, str]]]] = None
_determined_fields: Optional[Dict[str, List[FieldKey]]] = None
fields_detected = False

# these are set in self._parse_parameter_file()
Expand Down Expand Up @@ -862,7 +860,7 @@ def _setup_particle_types(self, ptypes=None):

def _get_field_info(
self,
field: Union[Tuple[str, str], str, DerivedField],
field: Union[FieldKey, ImplicitFieldKey, DerivedField],
/,
) -> DerivedField:
field_info, candidates = self._get_field_info_helper(field)
Expand All @@ -872,7 +870,7 @@ def _get_field_info(
# https://github.com/yt-project/yt/issues/3381
return field_info

def _are_ambiguous(candidates: List[Tuple[str, str]]) -> bool:
def _are_ambiguous(candidates: List[FieldKey]) -> bool:
if len(candidates) < 2:
return False

Expand Down Expand Up @@ -923,9 +921,9 @@ def _are_ambiguous(candidates: List[Tuple[str, str]]) -> bool:

def _get_field_info_helper(
self,
field: Union[Tuple[str, str], str, DerivedField],
field: Union[FieldKey, ImplicitFieldKey, DerivedField],
/,
) -> Tuple[DerivedField, List[Tuple[str, str]]]:
) -> Tuple[DerivedField, List[FieldKey]]:
self.index

ftype: str
Expand All @@ -940,7 +938,7 @@ def _get_field_info_helper(
raise YTFieldNotParseable(field)

if ftype == "unknown":
candidates: List[Tuple[str, str]] = [
candidates: List[FieldKey] = [
(ft, fn) for ft, fn in self.field_info if fn == fname
]

Expand Down

0 comments on commit 08c6866

Please sign in to comment.