Skip to content

Commit

Permalink
Post-rebase cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
terjekv committed Dec 13, 2023
1 parent b7666e7 commit 5cc6c1e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
10 changes: 6 additions & 4 deletions mreg_cli/outputmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""

import atexit
import datetime
import json
import os
import re
Expand Down Expand Up @@ -122,7 +123,7 @@ def __new__(cls):
return cls._instance

def clear(self) -> None:
"""Clears the object."""
"""Clear the object."""
self._output: List[str] = []
self._filter_re: Any = None # should be re.Pattern, but python 3.6 doesn't have that
self._filter_negate: bool = False
Expand All @@ -138,7 +139,7 @@ def clear(self) -> None:
self._time_started: datetime.datetime = datetime.datetime.now()

def recording_clear(self) -> None:
"""Clears the recording data."""
"""Clear the recording data."""
self._recorded_data: List[RecordingEntry] = []
self._recording: bool = False
self._filename: str = None
Expand Down Expand Up @@ -233,7 +234,7 @@ def add_ok(self, msg: str) -> None:
self._ok.append(msg)

def recording_active(self) -> bool:
"""Returns True if recording is active."""
"""Return True if recording is active."""
return self._recording

def recording_filename(self) -> Optional[str]:
Expand Down Expand Up @@ -261,6 +262,7 @@ def recording_output(self) -> None:
def recording_request(
self, method: str, url: str, params: str, data: Dict[str, Any], result: requests.Response
) -> None:
"""Record a request, if recording is active."""
if not self.recording_active():
return
ret_dict: Dict[str, Any] = {
Expand Down Expand Up @@ -426,7 +428,7 @@ def filtered_output(self) -> List[str]:
return [line for line in lines if filter_re.search(line)]

def render(self) -> None:
"""Prints the output to stdout, and records it if recording is active."""
"""Print the output to stdout, and records it if recording is active."""
self.recording_output()
for line in self.filtered_output():
print(line)
Expand Down
17 changes: 7 additions & 10 deletions mreg_cli/types.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
"""Type definitions for mreg_cli."""

import ipaddress
import sys
from typing import TYPE_CHECKING, Any, Dict, List, Optional
from typing import TYPE_CHECKING, Dict, List, Optional, Union

if sys.version_info >= (3, 8):
pass

if sys.version_info >= (3, 7):
from typing_extensions import TypedDict
from typing import Literal, TypedDict

class TimeInfo(TypedDict):
"""Type definition for time-related information in the recording entry."""
Expand All @@ -30,17 +28,16 @@ class RecordingEntry(TypedDict):
api_requests: List[str]
time: Optional[TimeInfo]

IP_Version = Literal[4, 6]

else:
from typing import Any

TimeInfo = Dict[str, Any]
RecordingEntry = Dict[str, Any]
IP_Version = int

try:
from typing import TypedDict # Python 3.8 and newer
except ImportError:
from typing_extensions import TypedDict # Python 3.6 and 3.7

IP_network = Union[ipaddress.IPv4Network, ipaddress.IPv6Network]

if TYPE_CHECKING:
from typing import Any
Expand Down

0 comments on commit 5cc6c1e

Please sign in to comment.