Skip to content

Commit

Permalink
Address ruff ANN (#1767)
Browse files Browse the repository at this point in the history
* Address ruff ANN exceptions

* Address ANN204
  • Loading branch information
shatakshiiii authored May 20, 2024
1 parent 02795a1 commit a2dfa86
Show file tree
Hide file tree
Showing 41 changed files with 45 additions and 51 deletions.
12 changes: 2 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -260,21 +260,13 @@ exclude = ["tests/fixtures/**", ".git"]

[tool.ruff.lint]
ignore = [
'ANN101', # This rule is deprecated and will be removed in a future release.
'ANN102', # This rule is deprecated and will be removed in a future release.
'ERA001', # [*] Found commented-out code
'INP001', # File `docs/_ext/regenerate_docs.py` is part of an implicit namespace package. Add an `__init__.py`.
'PLW2901', # `for` loop variable `info_name` overwritten by assignment target
"RET504", # Unnecessary variable assignment before `return` statement
# temporary disabled until we fix them:
'ANN001', # Missing type annotation for function argument `output`
'ANN002', # Missing type annotation for `*args`
'ANN003', # Missing type annotation for `**kwargs`
'ANN101', # Missing type annotation for `self` in method
'ANN102', # Missing type annotation for `cls` in classmethod
'ANN201', # Missing return type annotation for public function `notify_none`
'ANN202', # Missing return type annotation for private function `_build_main_menu`
'ANN204', # [*] Missing return type annotation for special method `__init__`
'ANN205', # Missing return type annotation for staticmethod `run_single_process`
'ANN206', # Missing return type annotation for classmethod `_missing_`
'ANN401', # Dynamically typed expressions (typing.Any) are disallowed in `cls`
'ARG001', # Unused function argument: `colno`
'ARG002', # Unused method argument: `app`
Expand Down
4 changes: 3 additions & 1 deletion src/ansible_navigator/action_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ class ActionBase:
# pylint: disable=too-many-instance-attributes
"""Base class for actions."""

def __init__(self, args: ApplicationConfiguration, name: str, logger_name: str = __name__):
def __init__(
self, args: ApplicationConfiguration, name: str, logger_name: str = __name__
) -> None:
"""Initialize the App class.
:param args: The current application configuration
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/back.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Action:

KEGEX = r"^\^\[|\x1b|back$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``:back`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Action(ActionBase):

KEGEX = "^b(?:uilder)?$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the action.
:param args: The current application configuration
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class Action(ActionBase):

KEGEX = r"^collections(\s(?P<params>.*))?$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``collections`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Action(ActionBase):

KEGEX = r"^config(\s(?P<params>.*))?$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``:config`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Action(ActionBase):

KEGEX = r"^d(?:oc)?(\s(?P<params>.*))?$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``doc`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Action(ActionBase):

KEGEX = "^e(?:xec)?$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``:exec`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Action:

KEGEX = r"^f(ilter)?(\s(?P<regex>.*))?$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``:filter`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/help_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Action(ActionBase):

KEGEX = r"^h(?:elp)?$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``:help`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Action(ActionBase):

KEGEX = r"^im(?:ages)?(\s(?P<params>.*))?$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``:images`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class Action(ActionBase):

KEGEX = r"^i(?:nventory)?(\s(?P<params>.*))?$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``:images`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class Action(ActionBase):

KEGEX = r"^lint(\s(?P<params>.*))?$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the action.
:param args: The current application configuration
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Action(ActionBase):

KEGEX = r"^l(?:og)?$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``:log`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/open_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Action:

KEGEX = r"^o(?:pen)?(\s(?P<requested>.*))?$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``:open`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/quit.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Action:

KEGEX = r"q(?:uit)?(?P<exclamation>!)?$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``:quit`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/refresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Action:

KEGEX = r"^KEY_F\(5\)$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the refresh action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/rerun.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Action:

KEGEX = r"^rr|rerun?$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``:rerun`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class Action(ActionBase):
(\s(?P<params_run>.*))?)
$"""

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``:run`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/sample_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Action(ActionBase):

KEGEX = r"^sample_form$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``:sample_form`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/sample_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Action(ActionBase):

KEGEX = r"^sample_notification$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``:sample_notification`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/sample_working.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Action(ActionBase):

KEGEX = r"^sample_working$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``:sample_working`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/save.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Action:

KEGEX = r"^s(?:ave)?\s(?P<filename>.*)$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``:save`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Action:

KEGEX = r"^\d+$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the select action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/serialize_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Action:

KEGEX = r"^j(?:son)?$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``:json`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/serialize_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Action:

KEGEX = r"^y(?:aml)?$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``:yaml`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Action(ActionBase):

KEGEX = r"^se(?:ttings)?$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``:settings`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/stdout.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Action(ActionBase):

KEGEX = r"^st(?:dout)?$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``:stdout`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Action(ActionBase):

KEGEX = r"^{{\s*(?P<params>.*?)\s*}}$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the template action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/welcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Action(ActionBase):

KEGEX = r"^welcome$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``:welcome`` action.
:param args: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/actions/write_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Action:

KEGEX = r"^w(?:rite)?(?P<force>!)?\s+(?P<append>>>)?\s*(?P<filename>.+)$"

def __init__(self, args: ApplicationConfiguration):
def __init__(self, args: ApplicationConfiguration) -> None:
"""Initialize the ``:write`` action.
:param args: The current settings for the application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(
application_configuration: ApplicationConfiguration,
apply_previous_cli_entries: list[str] | C = C.NONE,
skip_roll_back: bool = False,
):
) -> None:
"""Initialize the configuration variables.
:param params: A list of parameters e.g. ['-x', 'value']
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/configuration_subsystem/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class Parser:
"""Build the args."""

def __init__(self, config: ApplicationConfiguration):
def __init__(self, config: ApplicationConfiguration) -> None:
"""Initialize the command line interface parameter parser.
:param config: The current settings for the application
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/data/catalog_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
class CollectionCatalog:
"""A collection cataloger."""

def __init__(self, directories: list[Path]):
def __init__(self, directories: list[Path]) -> None:
"""Initialize the collection cataloger.
:param directories: A list of directories that may contain collections
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def __init__(
args: ApplicationConfiguration,
messages: list[LogMessage],
exit_messages: list[ExitMessage],
):
) -> None:
"""Initialize the ShowTech class.
:param args: The current settings
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/image_manager/puller.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(
image: str,
arguments: Constants | list[str],
pull_policy: str,
):
) -> None:
"""Initialize the container image puller.
:param container_engine: The name of the container engine
Expand Down
4 changes: 2 additions & 2 deletions src/ansible_navigator/ui_framework/colorize.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
class ColorSchema:
"""A storage mechanism for the schema (theme)."""

def __init__(self, schema: dict[str, str | list[Any] | dict[Any, Any]]):
def __init__(self, schema: dict[str, str | list[Any] | dict[Any, Any]]) -> None:
"""Initialize the ColorSchema class.
:param schema: The color scheme, theme to use
Expand Down Expand Up @@ -91,7 +91,7 @@ def get_color_and_style(self, scope: str) -> tuple[RgbTuple | None, str | None]:
class Colorize:
"""Functionality for coloring."""

def __init__(self, grammar_dir: Traversable, theme_path: Traversable):
def __init__(self, grammar_dir: Traversable, theme_path: Traversable) -> None:
"""Initialize the colorizer.
:param grammar_dir: The directory in which the grammars reside
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/ui_framework/curses_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CursesWindow:
# pylint: disable=too-many-instance-attributes
"""Abstraction for a curses window."""

def __init__(self, ui_config: UIConfig):
def __init__(self, ui_config: UIConfig) -> None:
"""Initialize a curses window.
:param ui_config: The current user interface configuration
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/ui_framework/menu_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(
number_colors: int,
color_menu_item: Callable[..., Any],
ui_config: UIConfig,
):
) -> None:
"""Initialize the menu builder.
:param progress_bar_width: The width of the progress bar
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/utils/key_value_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class KVSValuesView(ValuesView[str]):
class KeyValueStore(MutableMapping[str, str]):
"""An interface to use a sqlite database as a key-value store."""

def __init__(self, filename: str | Path):
def __init__(self, filename: str | Path) -> None:
"""Initialize the key-value store.
:param filename: The full path to the sqlite database file
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class CliRunner:
def __init__(
self,
request: pytest.FixtureRequest,
):
) -> None:
"""Initialize the class.
:param request: The current test request.
Expand Down

0 comments on commit a2dfa86

Please sign in to comment.