Add stubs for flake8-plugin-utils (#6506)

This commit is contained in:
kasium
2021-12-13 01:38:10 +01:00
committed by GitHub
parent a774e52fae
commit 383b5877bc
8 changed files with 71 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
flake8_plugin_utils
flake8_plugin_utils.plugin
flake8_plugin_utils.utils
flake8_plugin_utils.utils.assertions
flake8_plugin_utils.utils.constants
flake8_plugin_utils.utils.equiv_nodes

View File

@@ -0,0 +1 @@
version = "1.3.*"

View File

@@ -0,0 +1,9 @@
from .plugin import Error as Error, Plugin as Plugin, Visitor as Visitor
from .utils import (
assert_error as assert_error,
assert_not_error as assert_not_error,
check_equivalent_nodes as check_equivalent_nodes,
is_false as is_false,
is_none as is_none,
is_true as is_true,
)

View File

@@ -0,0 +1,36 @@
import argparse
import ast
from typing import Any, Generic, Iterable, Iterator, Tuple, Type, TypeVar
FLAKE8_ERROR = Tuple[int, int, str, Type[Any]]
TConfig = TypeVar("TConfig") # noqa: Y001
class Error:
code: str
message: str
lineno: int
col_offset: int
def __init__(self, lineno: int, col_offset: int, **kwargs: Any) -> None: ...
@classmethod
def formatted_message(cls, **kwargs: Any) -> str: ...
class Visitor(ast.NodeVisitor, Generic[TConfig]):
errors: list[Error]
def __init__(self, config: TConfig | None = ...) -> None: ...
@property
def config(self) -> TConfig: ...
def error_from_node(self, error: Type[Error], node: ast.AST, **kwargs: Any) -> None: ...
class Plugin(Generic[TConfig]):
name: str
version: str
visitors: list[Type[Visitor[TConfig]]]
config: TConfig
def __init__(self, tree: ast.AST) -> None: ...
def run(self) -> Iterable[FLAKE8_ERROR]: ...
@classmethod
def parse_options(cls, option_manager: Any, options: argparse.Namespace, args: list[str]) -> None: ...
@classmethod
def parse_options_to_config(cls, option_manager: Any, options: argparse.Namespace, args: list[str]) -> TConfig | None: ...
@classmethod
def test_config(cls, config: TConfig) -> Iterator[None]: ...

View File

@@ -0,0 +1,3 @@
from .assertions import assert_error as assert_error, assert_not_error as assert_not_error
from .constants import is_false as is_false, is_none as is_none, is_true as is_true
from .equiv_nodes import check_equivalent_nodes as check_equivalent_nodes

View File

@@ -0,0 +1,8 @@
from typing import Any, Type
from ..plugin import Error as Error, TConfig as TConfig, Visitor as Visitor
def assert_error(
visitor_cls: Type[Visitor[TConfig]], src: str, expected: Type[Error], config: TConfig | None = ..., **kwargs: Any
) -> None: ...
def assert_not_error(visitor_cls: Type[Visitor[TConfig]], src: str, config: TConfig | None = ...) -> None: ...

View File

@@ -0,0 +1,5 @@
import ast
def is_none(node: ast.AST) -> bool: ...
def is_false(node: ast.AST) -> bool: ...
def is_true(node: ast.AST) -> bool: ...

View File

@@ -0,0 +1,3 @@
import ast
def check_equivalent_nodes(node1: ast.AST, node2: ast.AST) -> bool: ...