Skip to content

Commit f960bd8

Browse files
authored
[inventory][chore] Bump libs (#2270)
1 parent aceca6b commit f960bd8

File tree

15 files changed

+123
-127
lines changed

15 files changed

+123
-127
lines changed

fixcore/fixcore/cli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def parse_time_or_delta(time_or_delta: str) -> datetime:
174174

175175
def js_value_get(element: JsonElement, path_or_name: Union[List[str], str], if_none: AnyT) -> AnyT:
176176
result = js_value_at(element, path_or_name)
177-
return result if result and isinstance(result, type(if_none)) else if_none # type: ignore
177+
return result if result and isinstance(result, type(if_none)) else if_none
178178

179179

180180
def js_value_at(element: JsonElement, path_or_name: Union[List[str], str]) -> Optional[Any]:

fixcore/fixcore/cli/model.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def __init__(
260260

261261
async def source(self) -> Tuple[CLISourceContext, JsStream]:
262262
res = self._fn()
263-
context, gen = await res if iscoroutine(res) else res
263+
context, gen = await res if iscoroutine(res) else res # type: ignore
264264
return context, self.make_stream(await gen if iscoroutine(gen) else gen)
265265

266266
@staticmethod
@@ -273,7 +273,7 @@ def only_count(
273273
) -> CLISource:
274274
async def combine() -> Tuple[CLISourceContext, JsGen]:
275275
res = fn()
276-
count, gen = await res if iscoroutine(res) else res
276+
count, gen = await res if iscoroutine(res) else res # type: ignore
277277
return CLISourceContext(count=count, total_count=count), gen
278278

279279
return CLISource(combine, produces, requires, envelope, required_permissions)
@@ -299,7 +299,7 @@ def with_count(
299299
) -> CLISource:
300300
async def combine() -> Tuple[CLISourceContext, JsGen]:
301301
res = fn()
302-
gen = await res if iscoroutine(res) else res
302+
gen: JsGen = await res if iscoroutine(res) else res # type: ignore
303303
return CLISourceContext(count=count), gen
304304

305305
return CLISource(combine, produces, requires, envelope, required_permissions)
@@ -333,7 +333,7 @@ def __init__(
333333

334334
async def flow(self, in_stream: JsGen) -> JsStream:
335335
gen = self._fn(self.make_stream(in_stream))
336-
return self.make_stream(await gen if iscoroutine(gen) else gen)
336+
return self.make_stream(await gen if iscoroutine(gen) else gen) # type: ignore
337337

338338

339339
@define

fixcore/fixcore/db/async_arangodb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(
5151
self.visited_edge: Set[str] = set()
5252
self.deferred_edges: List[Json] = []
5353
self.cursor_exhausted = False
54-
self.trafo: Callable[[Json], Optional[Any]] = trafo if trafo else identity # type: ignore
54+
self.trafo: Callable[[Json], Optional[Any]] = trafo if trafo else identity
5555
self.vt_len: Optional[int] = None
5656
self.on_hold: Optional[Json] = None
5757
self.get_next: Callable[[], Awaitable[Optional[Json]]] = (

fixcore/fixcore/db/graphdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,7 @@ async def execute_many_async(
12071207
) -> None:
12081208
if array:
12091209
async_fn_with_args = partial(async_fn, **kwargs) if kwargs else async_fn
1210-
result = await async_fn_with_args(name, array) # type: ignore
1210+
result = await async_fn_with_args(name, array)
12111211
ex: Optional[Exception] = first(lambda x: isinstance(x, Exception), result)
12121212
if ex:
12131213
raise ex # pylint: disable=raising-bad-type

fixcore/fixcore/model/adjust_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def first_matching(paths: List[List[str]]) -> Optional[str]:
4848
expires = DateTimeKind.from_datetime(expires_tag)
4949
else:
5050
expiration_tag = first_matching(self.expiration_values)
51-
if expiration_tag and expires_tag != "never" and DurationRe.fullmatch(expiration_tag):
51+
if expiration_tag and DurationRe.fullmatch(expiration_tag):
5252
ctime_str = value_in_path(json, NodePath.reported_ctime)
5353
if ctime_str:
5454
ctime = from_utc(ctime_str)

fixcore/fixcore/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def if_set(x: Optional[AnyT], func: Callable[[AnyT], Any], if_not: Any = None) -
278278

279279
def value_in_path_get(element: JsonElement, path_or_name: Union[List[str], str], if_none: AnyT) -> AnyT:
280280
result = value_in_path(element, path_or_name)
281-
return result if result is not None and isinstance(result, type(if_none)) else if_none # type: ignore
281+
return result if result is not None and isinstance(result, type(if_none)) else if_none
282282

283283

284284
def path_exists(element: JsonElement, path_or_name: Union[List[str], str]) -> bool:

fixcore/tests/fixcore/db/graphdb_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ async def test_update_node(filled_graph_db: ArangoGraphDB, foo_model: Model) ->
658658
async def elements(history: bool) -> List[Json]:
659659
fn = filled_graph_db.search_history if history else filled_graph_db.search_list
660660
model = QueryModel(parse_query("ancestors.account.reported.name==bat"), foo_model)
661-
async with await fn(query=model) as crs: # type: ignore
661+
async with await fn(query=model) as crs:
662662
return [e async for e in crs]
663663

664664
assert len(await elements(False)) == 111

fixlib/fixlib/asynchronous/web/runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ async def _run_app(
123123
sites: List[BaseSite] = []
124124

125125
def with_port(port: int, ssl: Optional[SSLContext] = None) -> None:
126-
if isinstance(host, (str, bytes, bytearray, memoryview)):
126+
if isinstance(host, (str, bytes, bytearray)):
127127
sites.append(
128128
TCPSite(
129129
runner,

fixlib/fixlib/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ def add_config(config: object) -> None:
108108
Config.running_config.classes[config.kind] = config # type: ignore
109109
Config.running_config.types[config.kind] = {}
110110
for field in fields(config): # type: ignore
111-
if hasattr(field, "type"):
112-
Config.running_config.types[config.kind][field.name] = optional_origin(field.type)
111+
if hasattr(field, "type") and isinstance(origin := optional_origin(field.type), type):
112+
Config.running_config.types[config.kind][field.name] = origin
113113
else:
114114
raise RuntimeError("Config must have a 'kind' attribute")
115115

fixlib/fixlib/core/model_export.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,43 +20,43 @@
2020

2121

2222
# List[X] -> list, list -> list
23-
def optional_origin(clazz: Type[Any]) -> Type[Any]:
23+
def optional_origin(clazz: Union[type, Tuple[Any], None]) -> Union[type, Tuple[Any], None]:
2424
maybe_optional = get_args(clazz)[0] if is_optional(clazz) else clazz
2525
origin = get_origin(maybe_optional)
26-
return origin if origin else maybe_optional # type: ignore
26+
return origin if origin else maybe_optional
2727

2828

2929
# Optional[x] -> true
30-
def is_optional(clazz: Union[type, Tuple[Any]]) -> bool:
30+
def is_optional(clazz: Union[type, Tuple[Any], None]) -> bool:
3131
args = get_args(clazz)
3232
return get_origin(clazz) is Union and type(None) in args and len(args) == 2
3333

3434

3535
# List[x] -> true, list -> true
36-
def is_collection(clazz: type) -> bool:
36+
def is_collection(clazz: Union[type, Tuple[Any], None]) -> bool:
3737
return optional_origin(clazz) in [list, set, tuple]
3838

3939

4040
# Dict[x,y] -> true, dict -> true
41-
def is_dict(clazz: type) -> bool:
41+
def is_dict(clazz: Union[type, Tuple[Any], None]) -> bool:
4242
return optional_origin(clazz) in [dict]
4343

4444

4545
# either enum or optional enum
46-
def is_enum(clazz: type) -> bool:
46+
def is_enum(clazz: Union[type, Tuple[Any], None]) -> bool:
4747
origin = optional_origin(clazz)
4848
return isinstance(origin, type) and issubclass(origin, Enum)
4949

5050

5151
# List[X] -> X, list -> object
52-
def type_arg(clazz: type) -> type:
52+
def type_arg(clazz: Union[type, Tuple[Any], None]) -> type:
5353
maybe_optional = get_args(clazz)[0] if is_optional(clazz) else clazz
5454
args = get_args(maybe_optional)
55-
return args[0] if args and len(args) == 1 else object # type: ignore
55+
return args[0] if args and len(args) == 1 else object
5656

5757

5858
# Dict[X,Y] -> (X,Y), dict -> (object, object)
59-
def dict_types(clazz: type) -> Tuple[type, type]:
59+
def dict_types(clazz: Union[type, Tuple[Any], None]) -> Tuple[type, type]:
6060
maybe_optional = get_args(clazz)[0] if is_optional(clazz) else clazz
6161
args = get_args(maybe_optional)
6262
return (args[0], args[1]) if args and len(args) == 2 else (object, object)
@@ -76,7 +76,7 @@ def check(to_check: type) -> None:
7676
check(value_type)
7777
elif is_collection(clazz):
7878
check(type_arg(to_check))
79-
elif attrs.has(clazz):
79+
elif isinstance(clazz, type) and attrs.has(clazz):
8080
if getattr(clazz, "_model_export", True) is False:
8181
return
8282
resolve_types(clazz)
@@ -91,7 +91,7 @@ def check(to_check: type) -> None:
9191
continue
9292
check(field.type)
9393
elif is_enum(clazz):
94-
all_classes.add(clazz)
94+
all_classes.add(clazz) # type: ignore
9595

9696
for c in classes:
9797
check(c)
@@ -123,7 +123,7 @@ def model_name(clazz: Union[type, Tuple[Any], None]) -> str:
123123
return f"dictionary[{model_name(key_type)}, {model_name(value_type)}]"
124124
elif is_enum(to_check):
125125
# camel case to snake case
126-
return re.sub(r"(?<!^)(?=[A-Z])", "_", to_check.__name__).lower()
126+
return re.sub(r"(?<!^)(?=[A-Z])", "_", to_check.__name__).lower() # type: ignore
127127
elif get_origin(to_check) == Union:
128128
# this is a union of different types other than none.
129129
# since union types are not supported, we fallback to any here
@@ -132,7 +132,7 @@ def model_name(clazz: Union[type, Tuple[Any], None]) -> str:
132132
return model_name(get_args(to_check))
133133
elif isinstance(to_check, type) and issubclass(to_check, simple_type):
134134
return lookup[to_check]
135-
elif attrs.has(to_check):
135+
elif isinstance(to_check, type) and attrs.has(to_check):
136136
name = getattr(to_check, "kind", None)
137137
if not name:
138138
raise AttributeError(f"dataclass {to_check} need to define a ClassVar kind!")
@@ -191,7 +191,7 @@ def prop(field: Attribute) -> List[Json]: # type: ignore
191191
kind = meta.pop("type_hint", model_name(field.type))
192192
desc = meta.pop("description", None)
193193
desc = desc if with_prop_description else None
194-
required = meta.pop("required", use_optional_as_required and not is_optional(field.type)) # type: ignore
194+
required = meta.pop("required", use_optional_as_required and not is_optional(field.type))
195195
synthetic = meta.pop("synthetic", None)
196196
synthetic = synthetic if synthetic else {}
197197
for ps in property_metadata_to_strip:

0 commit comments

Comments
 (0)