mirror of
https://github.com/Instagram/LibCST.git
synced 2025-12-23 10:35:53 +00:00
The ufmt tool combines usort and black with a consistent wrapper, (#515)
which ensures we won't have inconsistent black-vs-isort errors going forward. We can always format by running `ufmt format .` at the root, and check with `ufmt check .` in our CI actions.
This commit is contained in:
parent
5928f6ad81
commit
5e1e3fe970
78 changed files with 31 additions and 110 deletions
3
.github/workflows/build.yml
vendored
3
.github/workflows/build.yml
vendored
|
|
@ -69,8 +69,7 @@ jobs:
|
|||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
run: exit 1
|
||||
- run: flake8
|
||||
- run: isort --check-only .
|
||||
- run: black --check libcst/
|
||||
- run: ufmt check .
|
||||
- run: python3 -m fixit.cli.run_rules
|
||||
|
||||
# Run pyre typechecker
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ disclosure of security bugs. In those cases, please go through the process
|
|||
outlined on that page and do not file a public issue.
|
||||
|
||||
## Coding Style
|
||||
We use flake8, isort and black to enforce coding style.
|
||||
We use flake8 and ufmt to enforce coding style.
|
||||
|
||||
## License
|
||||
By contributing to LibCST, you agree that your contributions will be licensed
|
||||
|
|
|
|||
|
|
@ -150,8 +150,8 @@ Start by setting up and activating a virtualenv:
|
|||
# If you're done with the virtualenv, you can leave it by running:
|
||||
deactivate
|
||||
|
||||
We use `isort <https://isort.readthedocs.io/en/stable/>`_ and `black <https://black.readthedocs.io/en/stable/>`_
|
||||
to format code. To format changes to be conformant, run the following in the root:
|
||||
We use `ufmt <https://ufmt.omnilib.dev/en/stable/>`_ to format code. To format
|
||||
changes to be conformant, run the following in the root:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@
|
|||
"source": [
|
||||
"Generate Source Code\n",
|
||||
"====================\n",
|
||||
"Generating the source code from a cst tree is as easy as accessing the :attr:`~libcst.Module.code` attribute on :class:`~libcst.Module`. After the code generation, we often use `Black <https://black.readthedocs.io/en/stable/>`_ and `isort <https://isort.readthedocs.io/en/stable/>`_ to reformate the code to keep a consistent coding style."
|
||||
"Generating the source code from a cst tree is as easy as accessing the :attr:`~libcst.Module.code` attribute on :class:`~libcst.Module`. After the code generation, we often use `ufmt <https://ufmt.omnilib.dev/en/stable/>`_ to reformate the code to keep a consistent coding style."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -192,7 +192,6 @@ from libcst._parser.types.config import (
|
|||
from libcst._removal_sentinel import RemovalSentinel, RemoveFromParent
|
||||
from libcst._visitors import CSTNodeT, CSTTransformer, CSTVisitor, CSTVisitorT
|
||||
|
||||
|
||||
try:
|
||||
from libcst._version import version as LIBCST_VERSION
|
||||
except ImportError:
|
||||
|
|
@ -207,7 +206,6 @@ from libcst.metadata.base_provider import (
|
|||
)
|
||||
from libcst.metadata.wrapper import MetadataWrapper
|
||||
|
||||
|
||||
__all__ = [
|
||||
"KNOWN_PYTHON_VERSION_STRINGS",
|
||||
"LIBCST_VERSION",
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
import dataclasses
|
||||
from typing import Any, Mapping, Type, TypeVar
|
||||
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ from libcst._metadata_dependent import MetadataDependent
|
|||
from libcst._typed_visitor import CSTTypedVisitorFunctions
|
||||
from libcst._visitors import CSTNodeT, CSTVisitor
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from libcst._nodes.base import CSTNode # noqa: F401
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ from libcst._parser.parso.python.token import PythonTokenTypes, TokenType
|
|||
from libcst._parser.types.token import Token
|
||||
from libcst._tabs import expand_tabs
|
||||
|
||||
|
||||
_EOF_STR: str = "end of file (EOF)"
|
||||
_INDENT_STR: str = "an indent"
|
||||
_DEDENT_STR: str = "a dedent"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
import sys
|
||||
|
||||
|
||||
# PEP 585
|
||||
if sys.version_info < (3, 9):
|
||||
from typing import Iterable, Sequence
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ from typing import (
|
|||
cast,
|
||||
)
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
# Circular dependency for typing reasons only
|
||||
from libcst._nodes.base import CSTNode # noqa: F401
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ from libcst._type_enforce import is_value_of_type
|
|||
from libcst._types import CSTNodeT
|
||||
from libcst._visitors import CSTTransformer, CSTVisitor, CSTVisitorT
|
||||
|
||||
|
||||
_CSTNodeSelfT = TypeVar("_CSTNodeSelfT", bound="CSTNode")
|
||||
_EMPTY_SEQUENCE: Sequence["CSTNode"] = ()
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ from libcst._maybe_sentinel import MaybeSentinel
|
|||
from libcst._removal_sentinel import RemovalSentinel
|
||||
from libcst._types import CSTNodeT
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
# These are circular dependencies only used for typing purposes
|
||||
from libcst._nodes.base import CSTNode # noqa: F401
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ from libcst._nodes.whitespace import EmptyLine
|
|||
from libcst._removal_sentinel import RemovalSentinel
|
||||
from libcst._visitors import CSTVisitorT
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
# This is circular, so import the type only in type checking
|
||||
from libcst._parser.types.config import PartialParserConfig
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ from libcst._nodes.whitespace import (
|
|||
)
|
||||
from libcst._visitors import CSTVisitorT
|
||||
|
||||
|
||||
_INDENT_WHITESPACE_RE: Pattern[str] = re.compile(r"[ \f\t]+", re.UNICODE)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ from libcst._types import CSTNodeT
|
|||
from libcst._visitors import CSTTransformer
|
||||
from libcst.testing.utils import UnitTest, data_provider, none_throws
|
||||
|
||||
|
||||
_EMPTY_SIMPLE_WHITESPACE = cst.SimpleWhitespace("")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ from libcst._nodes.internal import (
|
|||
)
|
||||
from libcst._visitors import CSTVisitorT
|
||||
|
||||
|
||||
# SimpleWhitespace includes continuation characters, which must be followed immediately
|
||||
# by a newline. SimpleWhitespace does not include other kinds of newlines, because those
|
||||
# may have semantic significance.
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ from libcst._parser.parso.pgen2.generator import DFAState, Grammar, ReservedStri
|
|||
from libcst._parser.parso.python.token import TokenType
|
||||
from libcst._parser.types.token import Token
|
||||
|
||||
|
||||
_NodeT = TypeVar("_NodeT")
|
||||
_TokenTypeT = TypeVar("_TokenTypeT", bound=TokenType)
|
||||
_TokenT = TypeVar("_TokenT", bound=Token)
|
||||
|
|
|
|||
|
|
@ -121,7 +121,6 @@ from libcst._parser.types.partials import (
|
|||
from libcst._parser.types.token import Token
|
||||
from libcst._parser.whitespace_parser import parse_parenthesizable_whitespace
|
||||
|
||||
|
||||
BINOP_TOKEN_LUT: typing.Dict[str, typing.Type[BaseBinaryOp]] = {
|
||||
"*": Multiply,
|
||||
"@": MatrixMultiply,
|
||||
|
|
|
|||
|
|
@ -101,7 +101,6 @@ from libcst._parser.whitespace_parser import (
|
|||
parse_simple_whitespace,
|
||||
)
|
||||
|
||||
|
||||
AUGOP_TOKEN_LUT: Dict[str, Type[BaseAugOp]] = {
|
||||
"+=": AddAssign,
|
||||
"-=": SubtractAssign,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
from itertools import zip_longest
|
||||
from typing import Iterable, Iterator, TypeVar
|
||||
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ from libcst._parser.types.config import AutoConfig, ParserConfig, PartialParserC
|
|||
from libcst._parser.types.token import Token
|
||||
from libcst._parser.wrapped_tokenize import tokenize_lines
|
||||
|
||||
|
||||
_INDENT: TokenType = PythonTokenTypes.INDENT
|
||||
_NAME: TokenType = PythonTokenTypes.NAME
|
||||
_NEWLINE: TokenType = PythonTokenTypes.NEWLINE
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ from libcst._parser.grammar import get_grammar, validate_grammar
|
|||
from libcst._parser.python_parser import PythonCSTParser
|
||||
from libcst._parser.types.config import PartialParserConfig
|
||||
|
||||
|
||||
_DEFAULT_PARTIAL_PARSER_CONFIG: PartialParserConfig = PartialParserConfig()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -141,7 +141,6 @@ from libcst._parser.types.config import AutoConfig
|
|||
from libcst._parser.types.conversions import NonterminalConversion, TerminalConversion
|
||||
from libcst._parser.types.production import Production
|
||||
|
||||
|
||||
# Keep this sorted alphabetically
|
||||
_TERMINAL_CONVERSIONS_SEQUENCE: Tuple[TerminalConversion, ...] = (
|
||||
convert_DEDENT,
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ from typing import Any, Generic, Mapping, Sequence, Set, TypeVar, Union
|
|||
|
||||
from libcst._parser.parso.pgen2.grammar_parser import GrammarParser, NFAState
|
||||
|
||||
|
||||
_TokenTypeT = TypeVar("_TokenTypeT")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ from typing import Dict, Generator, Iterable, Optional, Pattern, Set, Tuple
|
|||
from libcst._parser.parso.python.token import PythonTokenTypes
|
||||
from libcst._parser.parso.utils import PythonVersionInfo, split_lines
|
||||
|
||||
|
||||
# Maximum code point of Unicode 6.0: 0x10ffff (1,114,111)
|
||||
MAX_UNICODE = "\U0010ffff"
|
||||
BOM_UTF8_STRING = BOM_UTF8.decode("utf-8")
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ from libcst._parser.parso.python.tokenize import PythonToken, tokenize
|
|||
from libcst._parser.parso.utils import parse_version_string, split_lines
|
||||
from libcst.testing.utils import UnitTest, data_provider
|
||||
|
||||
|
||||
# To make it easier to access some of the token types, just put them here.
|
||||
NAME = PythonTokenTypes.NAME
|
||||
NEWLINE = PythonTokenTypes.NEWLINE
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ from ast import literal_eval
|
|||
from dataclasses import dataclass
|
||||
from typing import Optional, Sequence, Tuple, Union
|
||||
|
||||
|
||||
# The following is a list in Python that are line breaks in str.splitlines, but
|
||||
# not in Python. In Python only \r (Carriage Return, 0xD) and \n (Line Feed,
|
||||
# 0xA) are allowed to split lines.
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ from typing import Callable, Optional, Sequence, TypeVar
|
|||
from libcst._parser.types.conversions import NonterminalConversion
|
||||
from libcst._parser.types.production import Production
|
||||
|
||||
|
||||
_NonterminalConversionT = TypeVar(
|
||||
"_NonterminalConversionT", bound=NonterminalConversion
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ from libcst._parser.whitespace_parser import (
|
|||
)
|
||||
from libcst.testing.utils import UnitTest, data_provider
|
||||
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ from libcst._parser.types.whitespace_state import WhitespaceState
|
|||
from libcst._parser.wrapped_tokenize import Token, tokenize
|
||||
from libcst.testing.utils import UnitTest, data_provider
|
||||
|
||||
|
||||
_PY38 = parse_version_string("3.8.0")
|
||||
_PY37 = parse_version_string("3.7.0")
|
||||
_PY36 = parse_version_string("3.6.0")
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ from libcst._add_slots import add_slots
|
|||
from libcst._nodes.whitespace import NEWLINE_RE
|
||||
from libcst._parser.parso.utils import PythonVersionInfo, parse_version_string
|
||||
|
||||
|
||||
_INDENT_RE: Pattern[str] = re.compile(r"[ \t]+")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ from typing import Any, Callable, Sequence
|
|||
from libcst._parser.types.config import ParserConfig
|
||||
from libcst._parser.types.token import Token
|
||||
|
||||
|
||||
# pyre-fixme[33]: Aliased annotation cannot contain `Any`.
|
||||
NonterminalConversion = Callable[[ParserConfig, Sequence[Any]], Any]
|
||||
# pyre-fixme[33]: Aliased annotation cannot contain `Any`.
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ from libcst._nodes.statement import AsName, BaseSmallStatement, Decorator, Impor
|
|||
from libcst._nodes.whitespace import EmptyLine, SimpleWhitespace, TrailingWhitespace
|
||||
from libcst._parser.types.whitespace_state import WhitespaceState
|
||||
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ from libcst._nodes.whitespace import (
|
|||
from libcst._parser.types.config import BaseWhitespaceParserConfig
|
||||
from libcst._parser.types.whitespace_state import WhitespaceState as State
|
||||
|
||||
|
||||
# BEGIN PARSER ENTRYPOINTS
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ from libcst._parser.parso.utils import PythonVersionInfo, split_lines
|
|||
from libcst._parser.types.token import Token
|
||||
from libcst._parser.types.whitespace_state import WhitespaceState
|
||||
|
||||
|
||||
_ERRORTOKEN: TokenType = PythonTokenTypes.ERRORTOKEN
|
||||
_ERROR_DEDENT: TokenType = PythonTokenTypes.ERROR_DEDENT
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ from typing import Tuple, Union, cast, overload
|
|||
|
||||
from libcst._add_slots import add_slots
|
||||
|
||||
|
||||
_CodePositionT = Union[Tuple[int, int], "CodePosition"]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ from typing import Any, Iterable, Mapping, MutableMapping, MutableSequence, Tupl
|
|||
from typing_extensions import Literal
|
||||
from typing_inspect import get_args, get_origin, is_classvar, is_typevar, is_union_type
|
||||
|
||||
|
||||
try: # py37+
|
||||
from typing import ForwardRef
|
||||
except ImportError: # py36
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
|
||||
# This file was generated by libcst.codegen.gen_matcher_classes
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
from typing import Optional, Union, TYPE_CHECKING
|
||||
|
||||
from libcst._flatten_sentinel import FlattenSentinel
|
||||
from libcst._maybe_sentinel import MaybeSentinel
|
||||
|
|
@ -28,10 +28,10 @@ if TYPE_CHECKING:
|
|||
BinaryOperation,
|
||||
BooleanOperation,
|
||||
Call,
|
||||
Comparison,
|
||||
ComparisonTarget,
|
||||
CompFor,
|
||||
CompIf,
|
||||
Comparison,
|
||||
ComparisonTarget,
|
||||
ConcatenatedString,
|
||||
Dict,
|
||||
DictComp,
|
||||
|
|
@ -57,9 +57,9 @@ if TYPE_CHECKING:
|
|||
Name,
|
||||
NamedExpr,
|
||||
Param,
|
||||
Parameters,
|
||||
ParamSlash,
|
||||
ParamStar,
|
||||
Parameters,
|
||||
RightCurlyBrace,
|
||||
RightParen,
|
||||
RightSquareBracket,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
from typing import TYPE_CHECKING, Any, Callable, TypeVar, cast
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from libcst._typed_visitor import CSTTypedBaseFunctions # noqa: F401
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
from typing import TYPE_CHECKING, TypeVar
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from libcst._nodes.base import CSTNode # noqa: F401
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ from libcst._removal_sentinel import RemovalSentinel
|
|||
from libcst._typed_visitor import CSTTypedTransformerFunctions, CSTTypedVisitorFunctions
|
||||
from libcst._types import CSTNodeT
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
# Circular dependency for typing reasons only
|
||||
from libcst._nodes.base import CSTNode # noqa: F401
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import libcst as cst
|
|||
from libcst import ensure_type, parse_expression
|
||||
from libcst.codegen.gather import all_libcst_nodes, typeclasses
|
||||
|
||||
|
||||
CST_DIR: Set[str] = set(dir(cst))
|
||||
CLASS_RE = r"<class \'(.*?)\'>"
|
||||
OPTIONAL_RE = r"typing\.Union\[([^,]*?), NoneType]"
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ from typing import List
|
|||
|
||||
from libcst.codegen.gather import imports, nodebases, nodeuses
|
||||
|
||||
|
||||
generated_code: List[str] = []
|
||||
generated_code.append("# Copyright (c) Facebook, Inc. and its affiliates.")
|
||||
generated_code.append("#")
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ from typing import List
|
|||
|
||||
from libcst.codegen.gather import imports, nodebases, nodeuses
|
||||
|
||||
|
||||
generated_code: List[str] = []
|
||||
generated_code.append("# Copyright (c) Facebook, Inc. and its affiliates.")
|
||||
generated_code.append("#")
|
||||
|
|
|
|||
|
|
@ -26,8 +26,7 @@ from libcst.codegen.transforms import (
|
|||
|
||||
def format_file(fname: str) -> None:
|
||||
with open(os.devnull, "w") as devnull:
|
||||
subprocess.check_call(["isort", "-q", fname], stdout=devnull, stderr=devnull)
|
||||
subprocess.check_call(["black", fname], stdout=devnull, stderr=devnull)
|
||||
subprocess.check_call(["ufmt", "format", fname], stdout=devnull, stderr=devnull)
|
||||
|
||||
|
||||
def clean_generated_code(code: str) -> str:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ from libcst.codemod._runner import (
|
|||
from libcst.codemod._testing import CodemodTest
|
||||
from libcst.codemod._visitor import ContextAwareTransformer, ContextAwareVisitor
|
||||
|
||||
|
||||
__all__ = [
|
||||
"Codemod",
|
||||
"CodemodContext",
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ from libcst.codemod._runner import (
|
|||
)
|
||||
from libcst.metadata import FullRepoManager
|
||||
|
||||
|
||||
_DEFAULT_GENERATED_CODE_MARKER: str = f"@gen{''}erated"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ from libcst.codemod._visitor import ContextAwareTransformer
|
|||
from libcst.codemod.visitors._add_imports import AddImportsVisitor
|
||||
from libcst.codemod.visitors._remove_imports import RemoveImportsVisitor
|
||||
|
||||
|
||||
_Codemod = TypeVar("_Codemod", bound=Codemod)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
from types import TracebackType
|
||||
from typing import Callable, Generator, Iterable, Optional, Type, TypeVar
|
||||
|
||||
|
||||
RetT = TypeVar("RetT")
|
||||
ArgT = TypeVar("ArgT")
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ from typing import Optional, Sequence, Union
|
|||
from libcst import PartialParserConfig, parse_module
|
||||
from libcst.codemod._codemod import Codemod
|
||||
|
||||
|
||||
# All datastructures defined in this class are pickleable so that they can be used
|
||||
# as a return value with the multiprocessing module.
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import libcst as cst
|
|||
import libcst.matchers as m
|
||||
from libcst.codemod import VisitorBasedCodemodCommand
|
||||
|
||||
|
||||
USE_FSTRING_SIMPLE_EXPRESSION_MAX_LENGTH = 30
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ from libcst.codemod.visitors import GatherCommentsVisitor, RemoveImportsVisitor
|
|||
from libcst.helpers import get_absolute_module_for_import
|
||||
from libcst.metadata import PositionProvider, ProviderT
|
||||
|
||||
|
||||
DEFAULT_SUPPRESS_COMMENT_REGEX = (
|
||||
r".*\W(noqa|lint-ignore: ?unused-import|lint-ignore: ?F401)(\W.*)?$"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ from libcst.codemod.visitors._gather_string_annotation_names import (
|
|||
from libcst.codemod.visitors._gather_unused_imports import GatherUnusedImportsVisitor
|
||||
from libcst.codemod.visitors._remove_imports import RemoveImportsVisitor
|
||||
|
||||
|
||||
__all__ = [
|
||||
"AddImportsVisitor",
|
||||
"ApplyTypeAnnotationsVisitor",
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ from libcst.codemod._context import CodemodContext
|
|||
from libcst.codemod._visitor import ContextAwareVisitor
|
||||
from libcst.metadata import MetadataWrapper, QualifiedNameProvider
|
||||
|
||||
|
||||
FUNCS_CONSIDERED_AS_STRING_ANNOTATIONS = {"typing.TypeVar"}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ from libcst.codemod.visitors._gather_string_annotation_names import (
|
|||
from libcst.metadata import ProviderT, ScopeProvider
|
||||
from libcst.metadata.scope_provider import _gen_dotted_names
|
||||
|
||||
|
||||
MODULES_IGNORED_BY_DEFAULT = {"__future__"}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ from libcst.helpers.expression import (
|
|||
)
|
||||
from libcst.helpers.module import insert_header_comments
|
||||
|
||||
|
||||
__all__ = [
|
||||
"get_absolute_module_for_import",
|
||||
"get_absolute_module_for_import_or_raise",
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ from typing import Dict, Mapping, Optional, Set, Union
|
|||
import libcst as cst
|
||||
from libcst.helpers.common import ensure_type
|
||||
|
||||
|
||||
TEMPLATE_PREFIX: str = "__LIBCST_MANGLED_NAME_"
|
||||
TEMPLATE_SUFFIX: str = "_EMAN_DELGNAM_TSCBIL__"
|
||||
|
||||
|
|
|
|||
|
|
@ -11,25 +11,25 @@ from typing import Callable, Optional, Sequence, Union
|
|||
from typing_extensions import Literal
|
||||
|
||||
import libcst as cst
|
||||
from libcst.matchers._decorators import call_if_inside, call_if_not_inside, leave, visit
|
||||
from libcst.matchers._decorators import call_if_inside, call_if_not_inside, visit, leave
|
||||
from libcst.matchers._matcher_base import (
|
||||
AbstractBaseMatcherNodeMeta,
|
||||
AllOf,
|
||||
AtLeastN,
|
||||
AtMostN,
|
||||
BaseMatcherNode,
|
||||
DoesNotMatch,
|
||||
DoNotCare,
|
||||
DoNotCareSentinel,
|
||||
DoNotCare,
|
||||
TypeOf,
|
||||
OneOf,
|
||||
AllOf,
|
||||
DoesNotMatch,
|
||||
MatchIfTrue,
|
||||
MatchRegex,
|
||||
MatchMetadata,
|
||||
MatchMetadataIfTrue,
|
||||
MatchRegex,
|
||||
OneOf,
|
||||
SaveMatchedNode,
|
||||
TypeOf,
|
||||
ZeroOrMore,
|
||||
AtLeastN,
|
||||
ZeroOrOne,
|
||||
AtMostN,
|
||||
SaveMatchedNode,
|
||||
extract,
|
||||
extractall,
|
||||
findall,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ from typing import Callable, TypeVar
|
|||
|
||||
from libcst.matchers._matcher_base import BaseMatcherNode
|
||||
|
||||
|
||||
_CSTVisitFuncT = TypeVar("_CSTVisitFuncT")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@ from libcst._nodes.expression import (
|
|||
BinaryOperation,
|
||||
BooleanOperation,
|
||||
Call,
|
||||
Comparison,
|
||||
ComparisonTarget,
|
||||
CompFor,
|
||||
CompIf,
|
||||
Comparison,
|
||||
ComparisonTarget,
|
||||
ConcatenatedString,
|
||||
Dict,
|
||||
DictComp,
|
||||
|
|
@ -52,9 +52,9 @@ from libcst._nodes.expression import (
|
|||
Name,
|
||||
NamedExpr,
|
||||
Param,
|
||||
Parameters,
|
||||
ParamSlash,
|
||||
ParamStar,
|
||||
Parameters,
|
||||
RightCurlyBrace,
|
||||
RightParen,
|
||||
RightSquareBracket,
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ from libcst.matchers._matcher_base import (
|
|||
)
|
||||
from libcst.matchers._return_types import TYPED_FUNCTION_RETURN_MAPPING
|
||||
|
||||
|
||||
CONCRETE_METHODS: Set[str] = {
|
||||
*{f"visit_{cls.__name__}" for cls in TYPED_FUNCTION_RETURN_MAPPING},
|
||||
*{f"leave_{cls.__name__}" for cls in TYPED_FUNCTION_RETURN_MAPPING},
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ from libcst.metadata.span_provider import ByteSpanPositionProvider, CodeSpan
|
|||
from libcst.metadata.type_inference_provider import TypeInferenceProvider
|
||||
from libcst.metadata.wrapper import MetadataWrapper
|
||||
|
||||
|
||||
__all__ = [
|
||||
"CodePosition",
|
||||
"CodeRange",
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ from libcst._metadata_dependent import (
|
|||
)
|
||||
from libcst._visitors import CSTVisitor
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from libcst._nodes.base import CSTNode
|
||||
from libcst._nodes.module import Module, _ModuleSelfT as _ModuleT
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ from typing import TYPE_CHECKING, Collection, Dict, List, Mapping
|
|||
import libcst as cst
|
||||
from libcst.metadata.wrapper import MetadataWrapper
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from libcst.metadata.base_provider import ProviderT # noqa: F401
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ from libcst._nodes.module import Module
|
|||
from libcst._position import CodePosition, CodeRange
|
||||
from libcst.metadata.base_provider import BaseMetadataProvider
|
||||
|
||||
|
||||
NEWLINE_RE: Pattern[str] = re.compile(r"\r\n?|\n")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ from libcst.metadata.expression_context_provider import (
|
|||
ExpressionContextProvider,
|
||||
)
|
||||
|
||||
|
||||
# Comprehensions are handled separately in _visit_comp_alike due to
|
||||
# the complexity of the semantics
|
||||
_ASSIGNMENT_LIKE_NODES = (
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ from libcst.metadata.tests.test_type_inference_provider import _test_simple_clas
|
|||
from libcst.metadata.type_inference_provider import TypeInferenceProvider
|
||||
from libcst.testing.utils import UnitTest
|
||||
|
||||
|
||||
REPO_ROOT_DIR: str = str(Path(__file__).parent.parent.parent.resolve())
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ from libcst._batched_visitor import BatchableCSTVisitor, VisitorMethod, visit_ba
|
|||
from libcst._exceptions import MetadataException
|
||||
from libcst.metadata.base_provider import BatchableMetadataProvider
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from libcst._nodes.base import CSTNode # noqa: F401
|
||||
from libcst._nodes.module import Module # noqa: F401
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ from typing import (
|
|||
)
|
||||
from unittest import TestCase
|
||||
|
||||
|
||||
DATA_PROVIDER_DATA_ATTR_NAME = "__data_provider_data"
|
||||
DATA_PROVIDER_DESCRIPTION_PREFIX = "_data_provider_"
|
||||
PROVIDER_TEST_LIMIT_ATTR_NAME = "__provider_test_limit"
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ from hypothesmith import from_grammar
|
|||
|
||||
import libcst
|
||||
|
||||
|
||||
# If in doubt, you should use these "unit test" settings. They tune the timeouts
|
||||
# and example-reproduction behaviour for these tests' unusually large inputs.
|
||||
hypothesis.settings.register_profile(
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ from libcst.metadata.type_inference_provider import (
|
|||
)
|
||||
from libcst.testing.utils import UnitTest, data_provider
|
||||
|
||||
|
||||
TEST_SUITE_PATH: Path = Path(__file__).parent / "pyre"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ from typing_extensions import Literal
|
|||
from libcst._type_enforce import is_value_of_type
|
||||
from libcst.testing.utils import UnitTest, data_provider
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections import Counter # noqa: F401
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ from libcst.codemod import (
|
|||
parallel_exec_transform_with_prettyprint,
|
||||
)
|
||||
|
||||
|
||||
_DEFAULT_INDENT: str = " "
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,2 @@
|
|||
[tool.black]
|
||||
target-version = ["py36"]
|
||||
|
||||
[tool.isort]
|
||||
line_length = 88
|
||||
multi_line_output = 3
|
||||
include_trailing_comma = true
|
||||
force_grid_wrap = 0
|
||||
lines_after_imports = 2
|
||||
combine_as_imports = true
|
||||
|
|
|
|||
|
|
@ -2,14 +2,15 @@ black==20.8b1
|
|||
coverage>=4.5.4
|
||||
fixit==0.1.1
|
||||
flake8>=3.7.8
|
||||
git+https://github.com/jimmylai/sphinx.git@slots_type_annotation
|
||||
hypothesis>=4.36.0
|
||||
hypothesmith>=0.0.4
|
||||
git+https://github.com/jimmylai/sphinx.git@slots_type_annotation
|
||||
isort==5.5.3
|
||||
jupyter>=1.0.0
|
||||
nbsphinx>=0.4.2
|
||||
pyre-check==0.0.41
|
||||
sphinx-rtd-theme>=0.4.3
|
||||
prompt-toolkit>=2.0.9
|
||||
tox>=3.18.1
|
||||
pyre-check==0.0.41
|
||||
setuptools_scm>=6.0.1
|
||||
sphinx-rtd-theme>=0.4.3
|
||||
tox>=3.18.1
|
||||
ufmt==1.2
|
||||
usort==0.6.3
|
||||
|
|
|
|||
1
setup.py
1
setup.py
|
|
@ -8,7 +8,6 @@ from os import path
|
|||
|
||||
import setuptools
|
||||
|
||||
|
||||
# Grab the readme so that our package stays in sync with github.
|
||||
this_directory: str = path.abspath(path.dirname(__file__))
|
||||
with open(path.join(this_directory, "README.rst"), encoding="utf-8") as f:
|
||||
|
|
|
|||
|
|
@ -66,7 +66,6 @@ from token import (
|
|||
)
|
||||
from typing import Callable, Generator, Sequence, Tuple
|
||||
|
||||
|
||||
Hexnumber: str = ...
|
||||
Binnumber: str = ...
|
||||
Octnumber: str = ...
|
||||
|
|
|
|||
6
tox.ini
6
tox.ini
|
|
@ -20,8 +20,7 @@ commands =
|
|||
[testenv:lint]
|
||||
commands =
|
||||
flake8 {posargs}
|
||||
isort --check-only {posargs:.}
|
||||
black --check {posargs:libcst/}
|
||||
ufmt check {posargs:.}
|
||||
python3 -m fixit.cli.run_rules
|
||||
|
||||
[testenv:docs]
|
||||
|
|
@ -31,8 +30,7 @@ commands =
|
|||
[testenv:autofix]
|
||||
commands =
|
||||
flake8 {posargs}
|
||||
isort -q {posargs:.}
|
||||
black {posargs:libcst/}
|
||||
ufmt format {posargs:.}
|
||||
python3 -m fixit.cli.apply_fix
|
||||
|
||||
[testenv:pyre]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue