Skip to content

Commit

Permalink
fix some annotation lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mcflugen committed Feb 29, 2024
1 parent dcf746c commit 1238a64
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/standard_names/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def _get_latest_names_file(
return None, None


class NamesRegistry(MutableSet):
class NamesRegistry(MutableSet[str]):

"""A registry of CSDMS Standard Names.
Expand Down Expand Up @@ -247,18 +247,18 @@ def version(self) -> str:
return self._version

@property
def names(self) -> tuple[str, ...]:
def names(self) -> frozenset[str]:
"""All names in the registry.
Returns
-------
tuple of str
All of the names in the registry.
"""
return tuple(self._names)
return frozenset(self._names)

@property
def objects(self) -> tuple[str, ...]:
def objects(self) -> frozenset[str]:
"""All objects in the registry.
Returns
Expand All @@ -269,7 +269,7 @@ def objects(self) -> tuple[str, ...]:
return frozenset(self._objects)

@property
def quantities(self) -> tuple[str, ...]:
def quantities(self) -> frozenset[str]:
"""All quantities in the registry.
Returns
Expand All @@ -280,7 +280,7 @@ def quantities(self) -> tuple[str, ...]:
return frozenset(self._quantities)

@property
def operators(self) -> tuple[str, ...]:
def operators(self) -> frozenset[str]:
"""All operators in the registry.
Returns
Expand Down Expand Up @@ -340,7 +340,7 @@ def add(self, name: str | StandardName) -> None:
for op in name.operators:
self._operators[op].add(name.name)

def discard(self, name: str | StandardName):
def discard(self, name: str | StandardName) -> None:
if isinstance(name, str):
try:
name = StandardName(name)
Expand All @@ -364,13 +364,16 @@ def discard(self, name: str | StandardName):
if not self._operators[op]:
del self._operators[op]

def __contains__(self, name: str) -> bool:
def __contains__(self, name: object) -> bool:
if isinstance(name, StandardName):
try:
name = name.name
except BadNameError:
return False
return name in self._names
if isinstance(name, str):
return name in self._names
else:
return NotImplemented

def __len__(self) -> int:
return len(self._names)
Expand Down

0 comments on commit 1238a64

Please sign in to comment.