Skip to content

Commit

Permalink
Bump version, linting.
Browse files Browse the repository at this point in the history
Signed-off-by: Caroline Russell <caroline@appthreat.dev>
  • Loading branch information
cerrussell committed Mar 12, 2024
1 parent aafd4c7 commit 750e9e9
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion atom_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -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'
10 changes: 9 additions & 1 deletion atom_tools/cli/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion atom_tools/cli/commands/command.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions atom_tools/cli/logging_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# pylint: disable-all
# Adapted from poetry
from __future__ import annotations

import sys
Expand Down
16 changes: 13 additions & 3 deletions atom_tools/lib/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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.
"""
Expand Down Expand Up @@ -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]:
"""
Expand Down
3 changes: 2 additions & 1 deletion atom_tools/lib/regex_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]] = {
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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" },
Expand Down

0 comments on commit 750e9e9

Please sign in to comment.