Skip to content

Commit 82066b3

Browse files
committed
pytests mostly
1 parent 01cd455 commit 82066b3

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

nodescraper/configbuilder.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
###############################################################################
2626
import enum
2727
import logging
28-
import types
2928
from typing import Any, Optional, Type, Union
3029

3130
from pydantic import BaseModel
@@ -80,7 +79,7 @@ def _update_config(cls, config_key, type_data: TypeData, config: dict):
8079
type_class_map = {
8180
type_class.type_class: type_class for type_class in type_data.type_classes
8281
}
83-
if types.NoneType in type_class_map:
82+
if type(None) in type_class_map:
8483
return
8584

8685
model_arg = next(

nodescraper/connection/inband/inbandremote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def read_file(
105105
106106
Args:
107107
filename (str): Path to file on remote host
108-
encoding (str | None, optional): If None, file is read as binary. If str, decode using that encoding. Defaults to "utf-8".
108+
encoding Optional[Union[str, None]]: If None, file is read as binary. If str, decode using that encoding. Defaults to "utf-8".
109109
strip (bool): Strip whitespace for text files. Ignored for binary.
110110
111111
Returns:

nodescraper/connection/inband/sshparams.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ class SSHConnectionParams(BaseModel):
3434
"""Class which holds info for an SSH connection"""
3535

3636
model_config = ConfigDict(arbitrary_types_allowed=True)
37+
3738
hostname: Union[IPvAnyAddress, str]
3839
username: str
3940
password: Optional[SecretStr] = None
4041
pkey: Optional[PKey] = None
4142
key_filename: Optional[str] = None
42-
port: Annotated[int, Field(strict=True, gt=0, lt=65536)] = 22
43+
port: Annotated[int, Field(strict=True, gt=0, le=65535)] = 22

nodescraper/plugins/inband/dmesg/dmesgdata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def import_model(cls, model_input: Union[dict, str]) -> "DmesgData":
9292
"""Load dmesg data
9393
9494
Args:
95-
model_input (dict | str): dmesg file name or dmesg data dict
95+
model_input Union[dict, str]: dmesg file name or dmesg data dict
9696
9797
Raises:
9898
ValueError: id model data has an invalid value

nodescraper/resultcollators/tablesummary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def gen_str_table(headers: list[str], rows: list[str]):
5151
border = f"+{'+'.join('-' * (width + 2) for width in column_widths)}+"
5252

5353
def gen_row(row):
54-
return f"| {' | '.join(str(cell).ljust(width) for cell, width in zip(row, column_widths, strict=False))} |"
54+
return f"| {' | '.join(str(cell).ljust(width) for cell, width in zip(row, column_widths))} |"
5555

5656
table = [border, gen_row(headers), border, *[gen_row(row) for row in rows], border]
5757
return "\n".join(table)

nodescraper/typeutils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def get_generic_map(cls, class_type: Type[Any]) -> dict:
6161
gen_base = class_type.__orig_bases__[0]
6262
class_org = get_origin(gen_base)
6363
args = get_args(gen_base)
64-
generic_map = dict(zip(class_org.__parameters__, args, strict=False))
64+
generic_map = dict(zip(class_org.__parameters__, args))
6565
else:
6666
generic_map = {}
6767

@@ -122,9 +122,9 @@ def process_type(cls, input_type: type[Any]) -> list[TypeClass]:
122122
origin = get_origin(input_type)
123123
if origin is None:
124124
return [TypeClass(type_class=input_type)]
125-
if origin in [Union, types.UnionType]:
125+
if origin is Union or getattr(types, "UnionType", None) is origin:
126126
type_classes = []
127-
input_types = [arg for arg in input_type.__args__ if arg != types.NoneType]
127+
input_types = [arg for arg in input_type.__args__ if arg is not type(None)]
128128
for type_item in input_types:
129129
origin = get_origin(type_item)
130130
if origin is None:
@@ -134,7 +134,7 @@ def process_type(cls, input_type: type[Any]) -> list[TypeClass]:
134134
TypeClass(
135135
type_class=origin,
136136
inner_type=next(
137-
(arg for arg in get_args(type_item) if arg != types.NoneType), None
137+
(arg for arg in get_args(type_item) if arg is not type(None)), None
138138
),
139139
)
140140
)
@@ -145,7 +145,7 @@ def process_type(cls, input_type: type[Any]) -> list[TypeClass]:
145145
TypeClass(
146146
type_class=origin,
147147
inner_type=next(
148-
(arg for arg in get_args(input_type) if arg != types.NoneType), None
148+
(arg for arg in get_args(input_type) if arg is not type(None)), None
149149
),
150150
)
151151
]

test/unit/framework/test_type_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# SOFTWARE.
2424
#
2525
###############################################################################
26-
from typing import Generic, Optional, TypeVar
26+
from typing import Generic, Optional, TypeVar, Union
2727

2828
from pydantic import BaseModel
2929

@@ -37,7 +37,7 @@ class TestGenericBase(Generic[T]):
3737
def __init__(self, generic_type: T):
3838
self.generic_type = generic_type
3939

40-
def test_func(self, arg: list[str], arg2: bool | str, arg3: Optional[int] = None) -> T:
40+
def test_func(self, arg: list[str], arg2: Union[bool, str], arg3: Optional[int] = None) -> T:
4141
return self.generic_type
4242

4343

0 commit comments

Comments
 (0)