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
The wrong type annotation was used in the uniswap.uniswap.Uniswap class. The parameters provider, web3, factory_contract_addr and router_contract_addr of the constructor default to None but are not declared as Optional. This is very unfriendly to static type checkers (such as Pyright with strict type checking enabled). And it will generate a lot of type error prompts, but actually no problem.
At the same time, the type annotation format of address and private_key is confusing. In Python3.9 and below, the recommended declaration method is Optional[T] to indicate that the parameter can be None. And in 3.10+, its recommended to use T | None(also Union[T, None]). But here we can see the two different formats of type annotations are being used at the same time, which is confusing.
Also, I noticed that some function parameters/return values also have such annotations. Returns possible None but no Optional is declared. This will confuse the user for wasting more time debugging the type.
The text was updated successfully, but these errors were encountered:
These annotations used to be valid, as CI has been running passing typechecking for a while.
However, recently typecheckers like mypy (not only pylance) have started enforcing no-implicit-optional, which I remedied in this PR along with other typing issues reported with newer mypy: #320
The wrong type annotation was used in the
uniswap.uniswap.Uniswap
class. The parametersprovider
,web3
,factory_contract_addr
androuter_contract_addr
of the constructor default toNone
but are not declared asOptional
. This is very unfriendly to static type checkers (such as Pyright with strict type checking enabled). And it will generate a lot of type error prompts, but actually no problem.At the same time, the type annotation format of
address
andprivate_key
is confusing. In Python3.9 and below, the recommended declaration method isOptional[T]
to indicate that the parameter can beNone
. And in 3.10+, its recommended to useT | None
(alsoUnion[T, None]
). But here we can see the two different formats of type annotations are being used at the same time, which is confusing.I suggest changing it to the following:
Also, I noticed that some function parameters/return values also have such annotations. Returns possible
None
but noOptional
is declared. This will confuse the user for wasting more time debugging the type.The text was updated successfully, but these errors were encountered: