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
In quite a few places, function parameters with defaults are annotated with typing.Optional[T] (where T could be str, int, ...), I propose changing these to T where it is deemed to be the expected type of the variable for the rest of the block, and explicit None is not valid.
Note that this is not the same concept as an optional argument, which is one that has a default. An optional argument with a default does not require the Optional qualifier on its type annotation just because it is optional.
This is not merely due to aesthetics, in my experience, Optional qualifiers can create some annoying type checking issues with mypy. For example: test.py
Although a single cast , assert or isinstance may not be a big deal, if you have to use it repeatedly, especially in loops, it looks unclean and reduces performance.
In quite a few places, function parameters with defaults are annotated with
typing.Optional[T]
(whereT
could bestr
,int
, ...), I propose changing these toT
where it is deemed to be the expected type of the variable for the rest of the block, and explicitNone
is not valid.typing.Optional
docs says the following about default value type annotations.This is not merely due to aesthetics, in my experience,
Optional
qualifiers can create some annoying type checking issues with mypy. For example:test.py
Running
mypy
:Then you will need to do one of the following:
or
or
Although a single
cast
,assert
orisinstance
may not be a big deal, if you have to use it repeatedly, especially in loops, it looks unclean and reduces performance.Originally posted by @sayandipdutta in #75 (comment)
Related: #75 (comment)
The text was updated successfully, but these errors were encountered: