You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think I've discovered a few different issues after updating my pyarr dependency in one of my projects. Note that all of these are errors according to Pylance/Pyright.
RescanMovie is not a member of RadarrCommands, but it is in the doctext for it, and it is a valid command.
The type hint for the **kwargs for RadarrAPI.post_command should just be Union[int, list[int]], otherwise you get the following error:
Argument of type "int" cannot be assigned to parameter "movieId" of type "dict[str, int | list[int]] | None" in function "post_command"
Type "int" cannot be assigned to type "dict[str, int | list[int]] | None"
"int" is incompatible with "dict[str, int | list[int]]"
Type cannot be assigned to type "None" Pylance[reportGeneralTypeIssues]
(parameter) movie_id: int
The resulting usage within the function would be as if kwargs was a Dict[str, Union[int, list[int]], but just specifying the value type is how static type checkers analyze it.
If python.analysis.typeCheckingMode is set to strict, Pyright complains on almost every function that the types are partially unknown:
Type of "lookup_movie" is partially unknown
Type of "lookup_movie" is "(term: str) -> list[dict[str, Unknown]]" Pylance[reportUnknownMemberType]
I think that this one might be a Pylance/Pyright issue though, as from what I can tell, JsonDataType/JsonObject/JsonArray shouldn't be statically analyzed to have anything be unknown. Felt like pointing it out as it did break some stuff for me.
After looking into it further, it's because there are generics (namely, list and dict) that aren't being specified. I just cloned the repo and set Pyright checking to strict and a bunch of errors about this popped up. I assume this happens with mypy --strict as well. For example, JsonDataType should have list["JsonDataType"] and dict[str, "JsonDataType"] as part of the union instead of the bare generics list and dict (also, do the TypeVars in the types file have to be bound or can they just be normal Unions?).
Steps To Reproduce
No response
Expected behaviour
Definitives: RescanMovie should be added to RadarrCommands. The type hint for **kwargs in RadarrAPI.post_command and SonarrAPI.post_command should be updated (and probably the other *arrs if they have the same, I currently only use Radarr and Sonarr).
Would be nice: I do think there is also merit to declaring each possible function signature with typing.overload as described in #119, as I currently have to throw in a assert isinstance(ret_value, list) or assert isinstance(ret_value, dict) every time I call a function that returns Union[JsonArray, JsonObject] to stop any type checkers (pylance, mypy) from complaining.
For example, calling BaseArrAPI.get_root_folder() with no arguments always yields a JsonArray, and always yields a JsonObject if you pass an id_. Currently it yields a Union[JsonArray, JsonObject] no matter what arguments you pass it.
The partially unknown type error is probably not a pyarr issue.
I'm not familiar enough with Python type hinting to know exactly how to fix these issues, but the result of Pylance/Pyright (and mypy) not complaining when set to strict modes would be the desired outcome.
Pyarr Version
5.2.0
Python Version
3.10.0
Example Code
No response
Relevant log output
No response
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
Is there an existing issue for this?
Current Behaviour
I think I've discovered a few different issues after updating my pyarr dependency in one of my projects. Note that all of these are errors according to Pylance/Pyright.
RescanMovie
is not a member ofRadarrCommands
, but it is in the doctext for it, and it is a valid command.The type hint for the
**kwargs
forRadarrAPI.post_command
should just beUnion[int, list[int]]
, otherwise you get the following error:The resulting usage within the function would be as if
kwargs
was aDict[str, Union[int, list[int]]
, but just specifying the value type is how static type checkers analyze it.python.analysis.typeCheckingMode
is set tostrict
, Pyright complains on almost every function that the types are partially unknown:I think that this one might be a Pylance/Pyright issue though, as from what I can tell,JsonDataType/JsonObject/JsonArray
shouldn't be statically analyzed to have anything be unknown. Felt like pointing it out as it did break some stuff for me.After looking into it further, it's because there are generics (namely,
list
anddict
) that aren't being specified. I just cloned the repo and set Pyright checking to strict and a bunch of errors about this popped up. I assume this happens withmypy --strict
as well. For example,JsonDataType
should havelist["JsonDataType"]
anddict[str, "JsonDataType"]
as part of the union instead of the bare genericslist
anddict
(also, do theTypeVar
s in the types file have to be bound or can they just be normalUnion
s?).Steps To Reproduce
No response
Expected behaviour
Definitives:
RescanMovie
should be added toRadarrCommands
. The type hint for**kwargs
inRadarrAPI.post_command
andSonarrAPI.post_command
should be updated (and probably the other *arrs if they have the same, I currently only use Radarr and Sonarr).Would be nice: I do think there is also merit to declaring each possible function signature with
typing.overload
as described in #119, as I currently have to throw in aassert isinstance(ret_value, list)
orassert isinstance(ret_value, dict)
every time I call a function that returnsUnion[JsonArray, JsonObject]
to stop any type checkers (pylance, mypy) from complaining.For example, calling
BaseArrAPI.get_root_folder()
with no arguments always yields aJsonArray
, and always yields aJsonObject
if you pass anid_
. Currently it yields aUnion[JsonArray, JsonObject]
no matter what arguments you pass it.The partially unknown type error is probably not apyarr
issue.I'm not familiar enough with Python type hinting to know exactly how to fix these issues, but the result of Pylance/Pyright (and mypy) not complaining when set to strict modes would be the desired outcome.
Pyarr Version
5.2.0
Python Version
3.10.0
Example Code
No response
Relevant log output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: