From 750e9e9030e331a79d6f94de1f8c329d262d1d3e Mon Sep 17 00:00:00 2001 From: Caroline Russell Date: Tue, 12 Mar 2024 11:27:56 -0400 Subject: [PATCH] Bump version, linting. Signed-off-by: Caroline Russell --- atom_tools/__init__.py | 2 +- atom_tools/cli/application.py | 10 +++++++++- atom_tools/cli/commands/command.py | 2 +- atom_tools/cli/logging_config.py | 2 ++ atom_tools/lib/converter.py | 16 +++++++++++++--- atom_tools/lib/regex_utils.py | 3 ++- pyproject.toml | 2 +- 7 files changed, 29 insertions(+), 8 deletions(-) diff --git a/atom_tools/__init__.py b/atom_tools/__init__.py index 070ecc9..0591825 100644 --- a/atom_tools/__init__.py +++ b/atom_tools/__init__.py @@ -1,4 +1,4 @@ """ A cli, classes and functions for converting an atom slice to a different format """ -__version__ = '0.4.1' +__version__ = '0.4.2' diff --git a/atom_tools/cli/application.py b/atom_tools/cli/application.py index 50696f6..c1e798c 100644 --- a/atom_tools/cli/application.py +++ b/atom_tools/cli/application.py @@ -72,7 +72,15 @@ def __init__(self) -> None: self.set_command_loader(command_loader) @staticmethod - def register_command_loggers(event: Event, event_name: str, _: EventDispatcher) -> None: + def register_command_loggers(event: Event, event_name: str, _: EventDispatcher) -> None: # pylint: disable=unused-argument + """ + Registers the command loggers. + + Args: + event (Event): The event. + event_name (str): The event name. + _: EventDispatcher: The event dispatcher. + """ assert isinstance(event, ConsoleCommandEvent) command = event.command if not isinstance(command, Command): diff --git a/atom_tools/cli/commands/command.py b/atom_tools/cli/commands/command.py index 137ab83..afb9c2c 100644 --- a/atom_tools/cli/commands/command.py +++ b/atom_tools/cli/commands/command.py @@ -1,4 +1,4 @@ -# pylint: disable=missing-class-docstring,missing-function-docstring,missing-module-docstring +# pylint: disable-all from __future__ import annotations from typing import ClassVar diff --git a/atom_tools/cli/logging_config.py b/atom_tools/cli/logging_config.py index e20c077..74aa268 100644 --- a/atom_tools/cli/logging_config.py +++ b/atom_tools/cli/logging_config.py @@ -1,3 +1,5 @@ +# pylint: disable-all +# Adapted from poetry from __future__ import annotations import sys diff --git a/atom_tools/lib/converter.py b/atom_tools/lib/converter.py index f233d20..0b050a7 100644 --- a/atom_tools/lib/converter.py +++ b/atom_tools/lib/converter.py @@ -45,6 +45,7 @@ class OpenAPI: Methods: _create_ln_entries: Creates an x-atom-usages entry. + _identify_target_line_nums: Identifies targetObj line numbers. _filter_matches: Filters a list of matches based on certain criteria. _js_helper: Formats path sections which are parameters correctly. _process_methods_helper: Utility for process_methods. @@ -78,7 +79,7 @@ def __init__( self.file_endpoint_map: Dict = {} self.params: Dict[str, List[Dict]] = {} self.regex_param_count = 0 - self.target_line_nums = {} + self.target_line_nums: Dict[str, Dict] = {} def endpoints_to_openapi(self, server: str = '') -> Any: """ @@ -414,7 +415,13 @@ def create_paths_item(self, filename: str, paths_dict: Dict) -> Dict: return self._remove_nested_parameters(paths_object) def _paths_object_helper( - self, calls: List, ep: str, filename: str, call_line_numbers: List, line_number: int) -> Tuple[str, Dict]: + self, + calls: List, + ep: str, + filename: str, + call_line_numbers: List, + line_number: int | None + ) -> Tuple[str, Dict]: """ Creates a paths item object. """ @@ -565,7 +572,10 @@ def extract_endpoints(self, method: str) -> List[str]: if not method or not (matches := re.findall(regex.endpoints, method)): return [] matches = self._filter_matches(matches, method) - return [v for v in matches if v and v not in exclusions and not v.lower().startswith('/x-')] + return [ + v for v in matches + if v and v not in exclusions and not v.lower().startswith('/x-') + ] def _filter_matches(self, matches: List[str], code: str) -> List[str]: """ diff --git a/atom_tools/lib/regex_utils.py b/atom_tools/lib/regex_utils.py index af4b4be..ad8c695 100644 --- a/atom_tools/lib/regex_utils.py +++ b/atom_tools/lib/regex_utils.py @@ -61,6 +61,7 @@ def py_helper(endpoint: str, regex: OpenAPIRegexCollection) -> Tuple[str, List[D Handles Python path parameters. Args: endpoint (str): The endpoint string + regex (OpenAPIRegexCollection): The regex collection Returns: tuple[str,list]: The modified endpoint and parameters @@ -144,7 +145,7 @@ def create_tmp_regex_name(element: str, m: Tuple | str, count: int) -> Tuple[str def fwd_slash_repl(match: re.Match) -> str: """For substituting forward slashes.""" - return match['paren'].replace('/', '$L@$H') + return str(match['paren'].replace('/', '$L@$H')) operator_map: Dict[str, List[str]] = { diff --git a/pyproject.toml b/pyproject.toml index 3f02345..d22bdb4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "atom-tools" -version = "0.4.1" +version = "0.4.2" description = "Collection of tools for use with AppThreat/atom." authors = [ { name = "Caroline Russell", email = "caroline@appthreat.dev" },