mirror of
https://github.com/Instagram/LibCST.git
synced 2025-12-23 10:35:53 +00:00
Bump black from 23.12.1 to 24.8.0 (#1186)
* Bump black from 23.12.1 to 24.8.0 Bumps [black](https://github.com/psf/black) from 23.12.1 to 24.8.0. - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - [Commits](https://github.com/psf/black/compare/23.12.1...24.8.0) --- updated-dependencies: - dependency-name: black dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Update formatting --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Amethyst Reese <amethyst@n7.gg>
This commit is contained in:
parent
cdf9ef414f
commit
bf5fb4132e
17 changed files with 90 additions and 91 deletions
|
|
@ -292,8 +292,7 @@ class CSTNode(ABC):
|
|||
return False
|
||||
|
||||
@abstractmethod
|
||||
def _codegen_impl(self, state: CodegenState) -> None:
|
||||
...
|
||||
def _codegen_impl(self, state: CodegenState) -> None: ...
|
||||
|
||||
def _codegen(self, state: CodegenState, **kwargs: Any) -> None:
|
||||
state.before_codegen(self)
|
||||
|
|
|
|||
|
|
@ -1647,9 +1647,9 @@ class Annotation(CSTNode):
|
|||
#: colon or arrow.
|
||||
annotation: BaseExpression
|
||||
|
||||
whitespace_before_indicator: Union[
|
||||
BaseParenthesizableWhitespace, MaybeSentinel
|
||||
] = MaybeSentinel.DEFAULT
|
||||
whitespace_before_indicator: Union[BaseParenthesizableWhitespace, MaybeSentinel] = (
|
||||
MaybeSentinel.DEFAULT
|
||||
)
|
||||
whitespace_after_indicator: BaseParenthesizableWhitespace = SimpleWhitespace.field(
|
||||
" "
|
||||
)
|
||||
|
|
@ -2101,9 +2101,9 @@ class Lambda(BaseExpression):
|
|||
rpar: Sequence[RightParen] = ()
|
||||
|
||||
#: Whitespace after the lambda keyword, but before any argument or the colon.
|
||||
whitespace_after_lambda: Union[
|
||||
BaseParenthesizableWhitespace, MaybeSentinel
|
||||
] = MaybeSentinel.DEFAULT
|
||||
whitespace_after_lambda: Union[BaseParenthesizableWhitespace, MaybeSentinel] = (
|
||||
MaybeSentinel.DEFAULT
|
||||
)
|
||||
|
||||
def _safe_to_use_with_word_operator(self, position: ExpressionPosition) -> bool:
|
||||
if position == ExpressionPosition.LEFT:
|
||||
|
|
@ -2601,9 +2601,9 @@ class From(CSTNode):
|
|||
item: BaseExpression
|
||||
|
||||
#: The whitespace at the very start of this node.
|
||||
whitespace_before_from: Union[
|
||||
BaseParenthesizableWhitespace, MaybeSentinel
|
||||
] = MaybeSentinel.DEFAULT
|
||||
whitespace_before_from: Union[BaseParenthesizableWhitespace, MaybeSentinel] = (
|
||||
MaybeSentinel.DEFAULT
|
||||
)
|
||||
|
||||
#: The whitespace after the ``from`` keyword, but before the ``item``.
|
||||
whitespace_after_from: BaseParenthesizableWhitespace = SimpleWhitespace.field(" ")
|
||||
|
|
@ -2662,9 +2662,9 @@ class Yield(BaseExpression):
|
|||
rpar: Sequence[RightParen] = ()
|
||||
|
||||
#: Whitespace after the ``yield`` keyword, but before the ``value``.
|
||||
whitespace_after_yield: Union[
|
||||
BaseParenthesizableWhitespace, MaybeSentinel
|
||||
] = MaybeSentinel.DEFAULT
|
||||
whitespace_after_yield: Union[BaseParenthesizableWhitespace, MaybeSentinel] = (
|
||||
MaybeSentinel.DEFAULT
|
||||
)
|
||||
|
||||
def _validate(self) -> None:
|
||||
# Paren rules and such
|
||||
|
|
@ -2748,8 +2748,7 @@ class _BaseElementImpl(CSTNode, ABC):
|
|||
state: CodegenState,
|
||||
default_comma: bool = False,
|
||||
default_comma_whitespace: bool = False, # False for a single-item collection
|
||||
) -> None:
|
||||
...
|
||||
) -> None: ...
|
||||
|
||||
|
||||
class BaseElement(_BaseElementImpl, ABC):
|
||||
|
|
|
|||
|
|
@ -43,8 +43,7 @@ class _BaseOneTokenOp(CSTNode, ABC):
|
|||
self.whitespace_after._codegen(state)
|
||||
|
||||
@abstractmethod
|
||||
def _get_token(self) -> str:
|
||||
...
|
||||
def _get_token(self) -> str: ...
|
||||
|
||||
|
||||
class _BaseTwoTokenOp(CSTNode, ABC):
|
||||
|
|
@ -88,8 +87,7 @@ class _BaseTwoTokenOp(CSTNode, ABC):
|
|||
self.whitespace_after._codegen(state)
|
||||
|
||||
@abstractmethod
|
||||
def _get_tokens(self) -> Tuple[str, str]:
|
||||
...
|
||||
def _get_tokens(self) -> Tuple[str, str]: ...
|
||||
|
||||
|
||||
class BaseUnaryOp(CSTNode, ABC):
|
||||
|
|
@ -115,8 +113,7 @@ class BaseUnaryOp(CSTNode, ABC):
|
|||
self.whitespace_after._codegen(state)
|
||||
|
||||
@abstractmethod
|
||||
def _get_token(self) -> str:
|
||||
...
|
||||
def _get_token(self) -> str: ...
|
||||
|
||||
|
||||
class BaseBooleanOp(_BaseOneTokenOp, ABC):
|
||||
|
|
|
|||
|
|
@ -113,8 +113,7 @@ class BaseSmallStatement(CSTNode, ABC):
|
|||
@abstractmethod
|
||||
def _codegen_impl(
|
||||
self, state: CodegenState, default_semicolon: bool = False
|
||||
) -> None:
|
||||
...
|
||||
) -> None: ...
|
||||
|
||||
|
||||
@add_slots
|
||||
|
|
@ -273,9 +272,9 @@ class Return(BaseSmallStatement):
|
|||
|
||||
#: Optional whitespace after the ``return`` keyword before the optional
|
||||
#: value expression.
|
||||
whitespace_after_return: Union[
|
||||
SimpleWhitespace, MaybeSentinel
|
||||
] = MaybeSentinel.DEFAULT
|
||||
whitespace_after_return: Union[SimpleWhitespace, MaybeSentinel] = (
|
||||
MaybeSentinel.DEFAULT
|
||||
)
|
||||
|
||||
#: Optional semicolon when this is used in a statement line. This semicolon
|
||||
#: owns the whitespace on both sides of it when it is used.
|
||||
|
|
@ -2403,9 +2402,9 @@ class Raise(BaseSmallStatement):
|
|||
cause: Optional[From] = None
|
||||
|
||||
#: Any whitespace appearing between the ``raise`` keyword and the exception.
|
||||
whitespace_after_raise: Union[
|
||||
SimpleWhitespace, MaybeSentinel
|
||||
] = MaybeSentinel.DEFAULT
|
||||
whitespace_after_raise: Union[SimpleWhitespace, MaybeSentinel] = (
|
||||
MaybeSentinel.DEFAULT
|
||||
)
|
||||
|
||||
#: Optional semicolon when this is used in a statement line. This semicolon
|
||||
#: owns the whitespace on both sides of it when it is used.
|
||||
|
|
@ -3423,15 +3422,15 @@ class MatchAs(MatchPattern):
|
|||
|
||||
#: Whitespace between ``pattern`` and the ``as`` keyword (if ``pattern`` is not
|
||||
#: ``None``)
|
||||
whitespace_before_as: Union[
|
||||
BaseParenthesizableWhitespace, MaybeSentinel
|
||||
] = MaybeSentinel.DEFAULT
|
||||
whitespace_before_as: Union[BaseParenthesizableWhitespace, MaybeSentinel] = (
|
||||
MaybeSentinel.DEFAULT
|
||||
)
|
||||
|
||||
#: Whitespace between the ``as`` keyword and ``name`` (if ``pattern`` is not
|
||||
#: ``None``)
|
||||
whitespace_after_as: Union[
|
||||
BaseParenthesizableWhitespace, MaybeSentinel
|
||||
] = MaybeSentinel.DEFAULT
|
||||
whitespace_after_as: Union[BaseParenthesizableWhitespace, MaybeSentinel] = (
|
||||
MaybeSentinel.DEFAULT
|
||||
)
|
||||
|
||||
#: Parenthesis at the beginning of the node
|
||||
lpar: Sequence[LeftParen] = ()
|
||||
|
|
@ -3774,16 +3773,16 @@ class TypeAlias(BaseSmallStatement):
|
|||
#: Whitespace between the name and the type parameters (if they exist) or the ``=``.
|
||||
#: If not specified, :class:`MaybeSentinel` will be replaced with a single space if
|
||||
#: there are no type parameters, otherwise no spaces.
|
||||
whitespace_after_name: Union[
|
||||
SimpleWhitespace, MaybeSentinel
|
||||
] = MaybeSentinel.DEFAULT
|
||||
whitespace_after_name: Union[SimpleWhitespace, MaybeSentinel] = (
|
||||
MaybeSentinel.DEFAULT
|
||||
)
|
||||
|
||||
#: Whitespace between the type parameters and the ``=``. Always empty if there are
|
||||
#: no type parameters. If not specified, :class:`MaybeSentinel` will be replaced
|
||||
#: with a single space if there are type parameters.
|
||||
whitespace_after_type_parameters: Union[
|
||||
SimpleWhitespace, MaybeSentinel
|
||||
] = MaybeSentinel.DEFAULT
|
||||
whitespace_after_type_parameters: Union[SimpleWhitespace, MaybeSentinel] = (
|
||||
MaybeSentinel.DEFAULT
|
||||
)
|
||||
|
||||
#: Whitespace between the ``=`` and the value.
|
||||
whitespace_after_equals: SimpleWhitespace = SimpleWhitespace.field(" ")
|
||||
|
|
|
|||
|
|
@ -129,11 +129,9 @@ class BaseParser(Generic[_TokenT, _TokenTypeT, _NodeT]):
|
|||
|
||||
def convert_nonterminal(
|
||||
self, nonterminal: str, children: Sequence[_NodeT]
|
||||
) -> _NodeT:
|
||||
...
|
||||
) -> _NodeT: ...
|
||||
|
||||
def convert_terminal(self, token: _TokenT) -> _NodeT:
|
||||
...
|
||||
def convert_terminal(self, token: _TokenT) -> _NodeT: ...
|
||||
|
||||
def _add_token(self, token: _TokenT) -> None:
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -72,9 +72,9 @@ class DFAState(Generic[_TokenTypeT]):
|
|||
def __init__(self, from_rule: str, nfa_set: Set[NFAState], final: NFAState) -> None:
|
||||
self.from_rule = from_rule
|
||||
self.nfa_set = nfa_set
|
||||
self.arcs: Mapping[
|
||||
str, DFAState
|
||||
] = {} # map from terminals/nonterminals to DFAState
|
||||
self.arcs: Mapping[str, DFAState] = (
|
||||
{}
|
||||
) # map from terminals/nonterminals to DFAState
|
||||
# In an intermediary step we set these nonterminal arcs (which has the
|
||||
# same structure as arcs). These don't contain terminals anymore.
|
||||
self.nonterminal_arcs: Mapping[str, DFAState] = {}
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ except ImportError:
|
|||
|
||||
BaseWhitespaceParserConfig = config_mod.BaseWhitespaceParserConfig
|
||||
ParserConfig = config_mod.ParserConfig
|
||||
parser_config_asdict: Callable[
|
||||
[ParserConfig], Mapping[str, Any]
|
||||
] = config_mod.parser_config_asdict
|
||||
parser_config_asdict: Callable[[ParserConfig], Mapping[str, Any]] = (
|
||||
config_mod.parser_config_asdict
|
||||
)
|
||||
|
||||
|
||||
class AutoConfig(Enum):
|
||||
|
|
|
|||
|
|
@ -40,12 +40,10 @@ class CodeRange:
|
|||
end: CodePosition
|
||||
|
||||
@overload
|
||||
def __init__(self, start: CodePosition, end: CodePosition) -> None:
|
||||
...
|
||||
def __init__(self, start: CodePosition, end: CodePosition) -> None: ...
|
||||
|
||||
@overload
|
||||
def __init__(self, start: Tuple[int, int], end: Tuple[int, int]) -> None:
|
||||
...
|
||||
def __init__(self, start: Tuple[int, int], end: Tuple[int, int]) -> None: ...
|
||||
|
||||
def __init__(self, start: _CodePositionT, end: _CodePositionT) -> None:
|
||||
if isinstance(start, tuple) and isinstance(end, tuple):
|
||||
|
|
|
|||
|
|
@ -207,6 +207,7 @@ if TYPE_CHECKING:
|
|||
|
||||
|
||||
class CSTTypedBaseFunctions:
|
||||
|
||||
@mark_no_op
|
||||
def visit_Add(self, node: "Add") -> Optional[bool]:
|
||||
pass
|
||||
|
|
@ -5763,6 +5764,7 @@ class CSTTypedBaseFunctions:
|
|||
|
||||
|
||||
class CSTTypedVisitorFunctions(CSTTypedBaseFunctions):
|
||||
|
||||
@mark_no_op
|
||||
def leave_Add(self, original_node: "Add") -> None:
|
||||
pass
|
||||
|
|
@ -6441,6 +6443,7 @@ class CSTTypedVisitorFunctions(CSTTypedBaseFunctions):
|
|||
|
||||
|
||||
class CSTTypedTransformerFunctions(CSTTypedBaseFunctions):
|
||||
|
||||
@mark_no_op
|
||||
def leave_Add(self, original_node: "Add", updated_node: "Add") -> "BaseBinaryOp":
|
||||
return updated_node
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@ class ConvertNamedTupleToDataclassCommand(VisitorBasedCodemodCommand):
|
|||
NamedTuple-specific attributes and methods.
|
||||
"""
|
||||
|
||||
DESCRIPTION: str = "Convert NamedTuple class declarations to Python 3.7 dataclasses using the @dataclass decorator."
|
||||
DESCRIPTION: str = (
|
||||
"Convert NamedTuple class declarations to Python 3.7 dataclasses using the @dataclass decorator."
|
||||
)
|
||||
METADATA_DEPENDENCIES: Sequence[ProviderT] = (QualifiedNameProvider,)
|
||||
|
||||
# The 'NamedTuple' we are interested in
|
||||
|
|
|
|||
|
|
@ -97,9 +97,11 @@ class ConvertPercentFormatStringCommand(VisitorBasedCodemodCommand):
|
|||
parts.append(cst.FormattedStringText(value=token))
|
||||
expressions: List[cst.CSTNode] = list(
|
||||
*itertools.chain(
|
||||
[elm.value for elm in expr.elements]
|
||||
if isinstance(expr, cst.Tuple)
|
||||
else [expr]
|
||||
(
|
||||
[elm.value for elm in expr.elements]
|
||||
if isinstance(expr, cst.Tuple)
|
||||
else [expr]
|
||||
)
|
||||
for expr in exprs
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -144,9 +144,9 @@ class RenameCommand(VisitorBasedCodemodCommand):
|
|||
self.bypass_import = True
|
||||
if replacement_module != import_alias_full_name:
|
||||
self.scheduled_removals.add(original_node)
|
||||
new_name_node: Union[
|
||||
cst.Attribute, cst.Name
|
||||
] = self.gen_name_or_attr_node(replacement_module)
|
||||
new_name_node: Union[cst.Attribute, cst.Name] = (
|
||||
self.gen_name_or_attr_node(replacement_module)
|
||||
)
|
||||
new_names.append(cst.ImportAlias(name=new_name_node))
|
||||
else:
|
||||
new_names.append(import_alias)
|
||||
|
|
@ -198,9 +198,9 @@ class RenameCommand(VisitorBasedCodemodCommand):
|
|||
self.scheduled_removals.add(original_node)
|
||||
continue
|
||||
|
||||
new_import_alias_name: Union[
|
||||
cst.Attribute, cst.Name
|
||||
] = self.gen_name_or_attr_node(replacement_obj)
|
||||
new_import_alias_name: Union[cst.Attribute, cst.Name] = (
|
||||
self.gen_name_or_attr_node(replacement_obj)
|
||||
)
|
||||
# Rename on the spot only if this is the only imported name under the module.
|
||||
if len(names) == 1:
|
||||
updated_node = updated_node.with_changes(
|
||||
|
|
|
|||
|
|
@ -48,8 +48,7 @@ class GenCacheMethod(Protocol):
|
|||
*,
|
||||
timeout: Optional[int] = None,
|
||||
use_pyproject_toml: bool = False,
|
||||
) -> Mapping[str, object]:
|
||||
...
|
||||
) -> Mapping[str, object]: ...
|
||||
|
||||
|
||||
# We can't use an ABCMeta here, because of metaclass conflicts
|
||||
|
|
|
|||
|
|
@ -199,8 +199,7 @@ class BaseAssignment(abc.ABC):
|
|||
return -1
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_qualified_names_for(self, full_name: str) -> Set[QualifiedName]:
|
||||
...
|
||||
def get_qualified_names_for(self, full_name: str) -> Set[QualifiedName]: ...
|
||||
|
||||
|
||||
class Assignment(BaseAssignment):
|
||||
|
|
@ -225,9 +224,11 @@ class Assignment(BaseAssignment):
|
|||
def get_qualified_names_for(self, full_name: str) -> Set[QualifiedName]:
|
||||
return {
|
||||
QualifiedName(
|
||||
f"{self.scope._name_prefix}.{full_name}"
|
||||
if self.scope._name_prefix
|
||||
else full_name,
|
||||
(
|
||||
f"{self.scope._name_prefix}.{full_name}"
|
||||
if self.scope._name_prefix
|
||||
else full_name
|
||||
),
|
||||
QualifiedNameSource.LOCAL,
|
||||
)
|
||||
}
|
||||
|
|
@ -306,9 +307,11 @@ class ImportAssignment(Assignment):
|
|||
remaining_name = remaining_name.lstrip(".")
|
||||
results.add(
|
||||
QualifiedName(
|
||||
f"{real_name}.{remaining_name}"
|
||||
if remaining_name
|
||||
else real_name,
|
||||
(
|
||||
f"{real_name}.{remaining_name}"
|
||||
if remaining_name
|
||||
else real_name
|
||||
),
|
||||
QualifiedNameSource.IMPORT,
|
||||
)
|
||||
)
|
||||
|
|
@ -503,19 +506,16 @@ class Scope(abc.ABC):
|
|||
@abc.abstractmethod
|
||||
def _resolve_scope_for_access(
|
||||
self, name: str, from_scope: "Scope"
|
||||
) -> Set[BaseAssignment]:
|
||||
...
|
||||
) -> Set[BaseAssignment]: ...
|
||||
|
||||
def __hash__(self) -> int:
|
||||
return id(self)
|
||||
|
||||
@abc.abstractmethod
|
||||
def record_global_overwrite(self, name: str) -> None:
|
||||
...
|
||||
def record_global_overwrite(self, name: str) -> None: ...
|
||||
|
||||
@abc.abstractmethod
|
||||
def record_nonlocal_overwrite(self, name: str) -> None:
|
||||
...
|
||||
def record_nonlocal_overwrite(self, name: str) -> None: ...
|
||||
|
||||
def get_qualified_names_for(
|
||||
self, node: Union[str, cst.CSTNode]
|
||||
|
|
|
|||
|
|
@ -653,12 +653,16 @@ class ScopeProviderTest(UnitTest):
|
|||
for assignment in scope_of_outer_f["var"]
|
||||
},
|
||||
{
|
||||
outer_f_body_var.targets[0].target
|
||||
if isinstance(outer_f_body_var, cst.Assign)
|
||||
else outer_f_body_var,
|
||||
inner_f_body_var.targets[0].target
|
||||
if isinstance(inner_f_body_var, cst.Assign)
|
||||
else inner_f_body_var,
|
||||
(
|
||||
outer_f_body_var.targets[0].target
|
||||
if isinstance(outer_f_body_var, cst.Assign)
|
||||
else outer_f_body_var
|
||||
),
|
||||
(
|
||||
inner_f_body_var.targets[0].target
|
||||
if isinstance(inner_f_body_var, cst.Assign)
|
||||
else inner_f_body_var
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -461,8 +461,7 @@ class _SerializerBase(ABC):
|
|||
return f"{comments}{os.linesep}{self._serialize_impl(key, value)}{os.linesep}"
|
||||
|
||||
@abstractmethod
|
||||
def _serialize_impl(self, key: str, value: object) -> str:
|
||||
...
|
||||
def _serialize_impl(self, key: str, value: object) -> str: ...
|
||||
|
||||
|
||||
class _StrSerializer(_SerializerBase):
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ dependencies = ["pyyaml>=5.2"]
|
|||
|
||||
[project.optional-dependencies]
|
||||
dev = [
|
||||
"black==23.12.1",
|
||||
"black==24.8.0",
|
||||
"coverage[toml]>=4.5.4",
|
||||
"build>=0.10.0",
|
||||
"fixit==2.1.0",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue