basedpyright
basedpyright copied to clipboard
Don't flag conditional constant definitions (`reportConstantRedefinition`/`reportRedeclaration`)
Description
Apparently basedpyright does not support conditional constants (nor conditional class / type alias definitions). For example:
# pyright: reportUnreachable=false
import sys
class MacFoo: pass
class WinFoo: pass
class LinFoo: pass
if sys.platform == "darwin":
OS = "macOS"
type SysFoo = MacFoo # reportRedeclaration
class SysBar: pass # reportRedeclaration
elif sys.platform == "win32":
OS = "Windows" # reportConstantRedefinition
type SysFoo = WinFoo # reportRedeclaration
class SysBar: pass # reportRedeclaration
else:
OS = "Linux" # reportConstantRedefinition
type SysFoo = LinFoo
class SysBar: pass
This issue also affects pyright (playground link), but this was considered expected behaviour (upstream issue: https://github.com/microsoft/pyright/issues/5265).
hmm i thought we had an issue for this already but i guess not. thanks