python-decouple
python-decouple copied to clipboard
Pyright reportGeneralTypeIssues error with cast
Hello,
I am trying to use cast
to parse a parameter and use it as an argument for a function that uses type hints.
controller = Controller(
config("MAX_ALLOWED_POWER", cast=int),
)
class Controller:
def __init__(
self,
max_allowed_power: int,
):
self._max_allowed_power = max_allowed_power
But the LSP returns the following error:
Pyright: Argument of type "str | Unknown | bool" cannot be assigned to parameter "max_allowed_power" of type "int" in function "__init__"
Type "str | Unknown | bool" cannot be assigned to type "int"
str" is incompatible with "int" [reportGeneralTypeIssues]
Am I doing something wrong? Thanks!