🚧 A expremental linter based on Pyright at early stage of development. Do not use it in production. 🚧
Require consistently using either X | Y or Union[X, Y] for union type declarations.
from typing import Union
a: Union[int, float]
# ⚠️ Use `|` instead of `Typing.Union`.Disallow the Any type.
a: Any
# ⚠️ Unexpected Any. Specify a different type.Disallow Awaitable in places not designed to handle them.
import asyncio
async def foo():
pass
if foo():
pass
# ⚠️ Expected non-Awaitable value in a boolean conditional. Did you forget to use 'await'?Disallow members of unions that do nothing.
foo: Any | int = 1
# ⚠️ 'Any' overrides all other types in this union type.
bar: int | Literal[1] = 1
# ⚠️ 'Literal[1]' is overridden by 'int' in this union type.Enforce that Self is used when only Self type is returned.
class Foo:
def foo(self) -> "Foo":
return self
# ⚠️ Use `Self` type instead.Enforce template literal expressions to be of string type.
class Foo:
pass
f"{Foo()}"
# ⚠️ Invalid type "Foo" of template literal expression.This project assumes you have configured pyright properly.
You can configure the rules in your pyright-lint.config.json file.
{
"include": ["**/*.py"],
"consistentUnionTypeDeclarations": true,
"noExplicitAny": true,
"noMisusedAwaitable": true,
"noRedundantTypeConstituents": true,
"preferReturnSelfType": true,
"restrictTemplateExpressions": true
}npm installnpm run testnpm run lintnpm run buildif you have any questions or suggestions, please create an issue.
MIT