Skip to content

Commit

Permalink
Address ruff D (#1754)
Browse files Browse the repository at this point in the history
  • Loading branch information
shatakshiiii committed May 10, 2024
1 parent 162074a commit a44d3ed
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,6 @@ ignore = [
'D101', # Missing docstring in public class
'D102', # Missing docstring in public method
'D103', # Missing docstring in public function
'D104', # Missing docstring in public package
'D105', # Missing docstring in magic method
'D400', # [*] First line should end with a period
'D403', # [*] First word of the first line should be capitalized: `tokenize` -> `Tokenize`
'E501', # line-too-long, already covered by black
'ERA001', # [*] Found commented-out code
'FBT001', # Boolean positional arg in function definition
Expand Down
1 change: 1 addition & 0 deletions src/ansible_navigator/tm_tokenize/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Initialization file for the tokenization subsystem."""
12 changes: 11 additions & 1 deletion src/ansible_navigator/tm_tokenize/fchainmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@


class Indexable(Generic[TKey_contra, TValue_co], Protocol):
def __getitem__(self, key: TKey_contra) -> TValue_co: ...
def __getitem__(self, key: TKey_contra) -> TValue_co:
"""Get the value associated with the given key.
:param key: The key to retrieve the value for.
"""


class FChainMap(Generic[TKey_contra, TValue_co]):
Expand All @@ -22,6 +26,12 @@ def __init__(self, *mappings: Indexable[TKey_contra, TValue_co]) -> None:
self._mappings = mappings

def __getitem__(self, key: TKey_contra) -> TValue_co:
"""Get the value associated with the given key.
:param key: The key to retrieve the value for.
:return: The value associated with the key.
:raises KeyError: If the key is not found in any of the mappings.
"""
for mapping in reversed(self._mappings):
try:
return mapping[key]
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/tm_tokenize/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Entry(NamedTuple):


class _Rule(Protocol):
"""hack for recursive types python/mypy#731"""
"""hack for recursive types python/mypy#731."""

@property
def name(self) -> tuple[str, ...]: ...
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/tm_tokenize/tokenize.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def tokenize(
line: str,
first_line: bool,
) -> tuple[State, Regions]:
"""tokenize a string into it's parts"""
"""Tokenize a string into it's parts."""
ret: list[Region] = []
pos = 0
boundary = state.cur.boundary
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/tm_tokenize/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@


def uniquely_constructed(t: T) -> T:
"""avoid tuple.__hash__ for "singleton" constructed objects"""
"""Avoid tuple.__hash__ for "singleton" constructed objects."""
t.__hash__ = object.__hash__ # type: ignore[assignment]
return t

0 comments on commit a44d3ed

Please sign in to comment.