diff --git a/CHANGELOG.md b/CHANGELOG.md index f72d53f0c..71f2bc83a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -265,7 +265,7 @@ ## Fixed * Fix type of `evaluated_value` on string to allow bytes by @ljodal in https://github.com/Instagram/LibCST/pull/721 -* Fix Sentinal typo by @kit1980 in https://github.com/Instagram/LibCST/pull/948 +* Fix Sentinel typo by @kit1980 in https://github.com/Instagram/LibCST/pull/948 * Allow no whitespace after lambda body in certain cases by @zsol in https://github.com/Instagram/LibCST/pull/939 * Fix whitespace, fstring, walrus related parse errors (#939, #938, #937, #936, #935, #934, #933, #932, #931) by @zsol in https://github.com/Instagram/LibCST/pull/940 @@ -346,7 +346,7 @@ the `LIBCST_PARSER_TYPE` environment variable set to `pure`. ## Added -* Python 3.11 rutime support +* Python 3.11 runtime support * test using python 3.11 beta versions by @zsol in https://github.com/Instagram/LibCST/pull/723 * Python 3.11 wheels by @vfazio in https://github.com/Instagram/LibCST/pull/801 * Raise informative exception when metadata is unresolved in a metadata-based match by @MapleCCC in https://github.com/Instagram/LibCST/pull/757 @@ -682,7 +682,7 @@ wheels from now on. ## Fixed - Spaces around walrus operator are not required [#368](https://github.com/Instagram/LibCST/pull/368) -- SaveMachedNode now matches with trailing empty wildcards [#356](https://github.com/Instagram/LibCST/pull/356) +- SaveMatchedNode now matches with trailing empty wildcards [#356](https://github.com/Instagram/LibCST/pull/356) - Correctly extract wildcard matchers [#355](https://github.com/Instagram/LibCST/pull/355) # 0.3.9 - 2020-09-07 @@ -857,7 +857,7 @@ wheels from now on. ## Updated - Codemod command can now discover codemods in subdirectories of configured modules. -- Updgraded Pyre dependency to 0.0.39. +- Upgraded Pyre dependency to 0.0.39. ## Fixed diff --git a/docs/source/nodes.rst b/docs/source/nodes.rst index 62e206ccf..65a5fbc9a 100644 --- a/docs/source/nodes.rst +++ b/docs/source/nodes.rst @@ -346,7 +346,7 @@ checks. Augmented Assignment Operators ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Nodes that are used with :class:`~libcst.AugAssign` to perform some agumented +Nodes that are used with :class:`~libcst.AugAssign` to perform some augmented assignment. .. class:: libcst.AddAssign @@ -371,7 +371,7 @@ checks. Miscellaneous ------------- -Miscelaneous nodes that are purely syntactic trivia. While python requires these nodes +Miscellaneous nodes that are purely syntactic trivia. While python requires these nodes in order to parse a module, statement or expression they do not carry any meaning on their own. diff --git a/docs/source/scope_tutorial.ipynb b/docs/source/scope_tutorial.ipynb index 179e2ed78..249574d84 100644 --- a/docs/source/scope_tutorial.ipynb +++ b/docs/source/scope_tutorial.ipynb @@ -135,7 +135,7 @@ "source": [ "Automatically Remove Unused Import\n", "==================================\n", - "Unused import is a commmon code suggestion provided by lint tool like `flake8 F401 `_ ``imported but unused``.\n", + "Unused import is a common code suggestion provided by lint tool like `flake8 F401 `_ ``imported but unused``.\n", "Even though reporting unused imports is already useful, with LibCST we can provide an automatic fix to remove unused imports. That can make the suggestion more actionable and save developer's time.\n", "\n", "An import statement may import multiple names, we want to remove those unused names from the import statement. If all the names in the import statement are not used, we remove the entire import.\n", diff --git a/libcst/_exceptions.py b/libcst/_exceptions.py index 4d3dd3865..a2bbaf51d 100644 --- a/libcst/_exceptions.py +++ b/libcst/_exceptions.py @@ -70,11 +70,11 @@ class ParserSyntaxError(Exception): # syntax error occurred in the code. _lines: Sequence[str] - #: The one-indexed line where the error occured. + #: The one-indexed line where the error occurred. raw_line: int #: The zero-indexed column as a number of characters from the start of the line - #: where the error occured. + #: where the error occurred. raw_column: int def __init__( diff --git a/libcst/_metadata_dependent.py b/libcst/_metadata_dependent.py index 4faf74727..319a356b8 100644 --- a/libcst/_metadata_dependent.py +++ b/libcst/_metadata_dependent.py @@ -40,7 +40,7 @@ class _UNDEFINED_DEFAULT: class LazyValue(Generic[_T]): """ The class for implementing a lazy metadata loading mechanism that improves the - performance when retriving expensive metadata (e.g., qualified names). Providers + performance when retrieving expensive metadata (e.g., qualified names). Providers including :class:`~libcst.metadata.QualifiedNameProvider` use this class to load the metadata of a certain node lazily when calling :func:`~libcst.MetadataDependent.get_metadata`. diff --git a/libcst/_nodes/expression.py b/libcst/_nodes/expression.py index eb95d9b3c..1522849b8 100644 --- a/libcst/_nodes/expression.py +++ b/libcst/_nodes/expression.py @@ -264,7 +264,7 @@ def _safe_to_use_with_word_operator(self, position: ExpressionPosition) -> bool: such as "not" without space between the operator an ourselves. Examples where this is true are "not(True)", "(1)in[1,2,3]", etc. This base function handles parenthesized nodes, but certain nodes such as tuples, - dictionaries and lists will override this to signifiy that they're always + dictionaries and lists will override this to signify that they're always safe. """ @@ -580,14 +580,14 @@ class SimpleString(_BasePrefixedString): (f-string), including triple-quoted multi-line strings. """ - #: The texual representation of the string, including quotes, prefix characters, and + #: The textual representation of the string, including quotes, prefix characters, and #: any escape characters present in the original source code , such as #: ``r"my string\n"``. To remove the quotes and interpret any escape characters, #: use the calculated property :attr:`~SimpleString.evaluated_value`. value: str lpar: Sequence[LeftParen] = () - #: Sequence of parenthesis for precidence dictation. + #: Sequence of parenthesis for precedence dictation. rpar: Sequence[RightParen] = () def _validate(self) -> None: @@ -898,7 +898,7 @@ class FormattedString(_BasePrefixedString): end: Literal['"', "'", '"""', "'''"] = '"' lpar: Sequence[LeftParen] = () - #: Sequence of parenthesis for precidence dictation. + #: Sequence of parenthesis for precedence dictation. rpar: Sequence[RightParen] = () def _validate(self) -> None: @@ -1145,7 +1145,7 @@ class TemplatedString(_BasePrefixedString): end: Literal['"', "'", '"""', "'''"] = '"' lpar: Sequence[LeftParen] = () - #: Sequence of parenthesis for precidence dictation. + #: Sequence of parenthesis for precedence dictation. rpar: Sequence[RightParen] = () def _validate(self) -> None: @@ -1226,7 +1226,7 @@ class ConcatenatedString(BaseString): right: Union[SimpleString, FormattedString, "ConcatenatedString"] lpar: Sequence[LeftParen] = () - #: Sequence of parenthesis for precidence dictation. + #: Sequence of parenthesis for precedence dictation. rpar: Sequence[RightParen] = () #: Whitespace between the ``left`` and ``right`` substrings. @@ -1346,7 +1346,7 @@ def _codegen_impl(self, state: CodegenState) -> None: class Comparison(BaseExpression): """ A comparison between multiple values such as ``x < y``, ``x < y < z``, or - ``x in [y, z]``. These comparisions typically result in boolean values. + ``x in [y, z]``. These comparisons typically result in boolean values. Unlike :class:`BinaryOperation` and :class:`BooleanOperation`, comparisons are not restricted to a left and right child. Instead they can contain an arbitrary number @@ -1372,7 +1372,7 @@ class Comparison(BaseExpression): """ #: The first value in the full sequence of values to compare. This value will be - #: compared against the first value in ``comparisions``. + #: compared against the first value in ``comparisons``. left: BaseExpression #: Pairs of :class:`BaseCompOp` operators and expression values to compare. These @@ -1503,7 +1503,7 @@ class BinaryOperation(BaseExpression): nodes, such as ``and`` or ``or``. Instead, those operations are provided by :class:`BooleanOperation`. - It also does not include support for comparision operators performed with + It also does not include support for comparison operators performed with :class:`BaseCompOp`, such as ``<``, ``>=``, ``==``, ``is``, or ``in``. Instead, those operations are provided by :class:`Comparison`. """ @@ -1556,7 +1556,7 @@ class BooleanOperation(BaseExpression): nodes, such as ``+`` or ``<<``. Instead, those operations are provided by :class:`BinaryOperation`. - It also does not include support for comparision operators performed with + It also does not include support for comparison operators performed with :class:`BaseCompOp`, such as ``<``, ``>=``, ``==``, ``is``, or ``in``. Instead, those operations are provided by :class:`Comparison`. """ @@ -2133,7 +2133,7 @@ class Parameters(CSTNode): #: parameters with defaults must all be after those without defaults. posonly_params: Sequence[Param] = () - #: Optional sentinel that dictates parameters preceeding are positional-only + #: Optional sentinel that dictates parameters preceding are positional-only #: args. posonly_ind: Union[ParamSlash, MaybeSentinel] = MaybeSentinel.DEFAULT @@ -3450,7 +3450,7 @@ def _validate(self) -> None: if len(self.elements) == 0: raise CSTValidationError( "A literal set must have at least one element. A zero-element set " - + "would be syntatically ambiguous with an empty dict, `{}`." + + "would be syntactically ambiguous with an empty dict, `{}`." ) def _visit_and_replace_children(self, visitor: CSTVisitorT) -> "Set": diff --git a/libcst/_nodes/op.py b/libcst/_nodes/op.py index 1765f5366..62b3f36db 100644 --- a/libcst/_nodes/op.py +++ b/libcst/_nodes/op.py @@ -49,7 +49,7 @@ def _get_token(self) -> str: ... class _BaseTwoTokenOp(CSTNode, ABC): """ Any node that ends up as two tokens, so we must preserve the whitespace - in beteween them. + in between them. """ __slots__ = () @@ -597,7 +597,7 @@ def _get_token(self) -> str: @dataclass(frozen=True) class LessThan(BaseCompOp, _BaseOneTokenOp): """ - A comparision operator that can be used in a :class:`Comparison` expression. + A comparison operator that can be used in a :class:`Comparison` expression. """ #: Any space that appears directly before this operator. @@ -614,7 +614,7 @@ def _get_token(self) -> str: @dataclass(frozen=True) class GreaterThan(BaseCompOp, _BaseOneTokenOp): """ - A comparision operator that can be used in a :class:`Comparison` expression. + A comparison operator that can be used in a :class:`Comparison` expression. """ #: Any space that appears directly before this operator. @@ -631,7 +631,7 @@ def _get_token(self) -> str: @dataclass(frozen=True) class Equal(BaseCompOp, _BaseOneTokenOp): """ - A comparision operator that can be used in a :class:`Comparison` expression. + A comparison operator that can be used in a :class:`Comparison` expression. """ #: Any space that appears directly before this operator. @@ -648,7 +648,7 @@ def _get_token(self) -> str: @dataclass(frozen=True) class LessThanEqual(BaseCompOp, _BaseOneTokenOp): """ - A comparision operator that can be used in a :class:`Comparison` expression. + A comparison operator that can be used in a :class:`Comparison` expression. """ #: Any space that appears directly before this operator. @@ -665,7 +665,7 @@ def _get_token(self) -> str: @dataclass(frozen=True) class GreaterThanEqual(BaseCompOp, _BaseOneTokenOp): """ - A comparision operator that can be used in a :class:`Comparison` expression. + A comparison operator that can be used in a :class:`Comparison` expression. """ #: Any space that appears directly before this operator. @@ -721,7 +721,7 @@ def _get_token(self) -> str: @dataclass(frozen=True) class In(BaseCompOp, _BaseOneTokenOp): """ - A comparision operator that can be used in a :class:`Comparison` expression. + A comparison operator that can be used in a :class:`Comparison` expression. """ #: Any space that appears directly before this operator. @@ -738,7 +738,7 @@ def _get_token(self) -> str: @dataclass(frozen=True) class NotIn(BaseCompOp, _BaseTwoTokenOp): """ - A comparision operator that can be used in a :class:`Comparison` expression. + A comparison operator that can be used in a :class:`Comparison` expression. This operator spans two tokens that must be separated by at least one space, so there is a third whitespace attribute to represent this. @@ -761,7 +761,7 @@ def _get_tokens(self) -> Tuple[str, str]: @dataclass(frozen=True) class Is(BaseCompOp, _BaseOneTokenOp): """ - A comparision operator that can be used in a :class:`Comparison` expression. + A comparison operator that can be used in a :class:`Comparison` expression. """ #: Any space that appears directly before this operator. @@ -778,7 +778,7 @@ def _get_token(self) -> str: @dataclass(frozen=True) class IsNot(BaseCompOp, _BaseTwoTokenOp): """ - A comparision operator that can be used in a :class:`Comparison` expression. + A comparison operator that can be used in a :class:`Comparison` expression. This operator spans two tokens that must be separated by at least one space, so there is a third whitespace attribute to represent this. diff --git a/libcst/_nodes/statement.py b/libcst/_nodes/statement.py index cdc49edc5..e52d0162a 100644 --- a/libcst/_nodes/statement.py +++ b/libcst/_nodes/statement.py @@ -392,7 +392,7 @@ def _validate(self) -> None: raise CSTValidationError( "All but the last SmallStatement in a SimpleStatementLine or " + "SimpleStatementSuite must have a trailing semicolon. Otherwise, " - + "there's no way to syntatically disambiguate each SmallStatement " + + "there's no way to syntactically disambiguate each SmallStatement " + "on the same line." ) @@ -678,7 +678,7 @@ class IndentedBlock(BaseSuite): indent: Optional[str] = None #: Any trailing comments or lines after the dedent that are owned by this indented - #: block. Statements own preceeding and same-line trailing comments, but not + #: block. Statements own preceding and same-line trailing comments, but not #: trailing lines, so it falls on :class:`IndentedBlock` to own it. In the case #: that a statement follows an :class:`IndentedBlock`, that statement will own the #: comments and lines that are at the same indent as the statement, and this @@ -2751,7 +2751,7 @@ class Match(BaseCompoundStatement): indent: Optional[str] = None #: Any trailing comments or lines after the dedent that are owned by this match - #: block. Statements own preceeding and same-line trailing comments, but not + #: block. Statements own preceding and same-line trailing comments, but not #: trailing lines, so it falls on :class:`Match` to own it. In the case #: that a statement follows a :class:`Match` block, that statement will own the #: comments and lines that are at the same indent as the statement, and this diff --git a/libcst/_nodes/tests/test_atom.py b/libcst/_nodes/tests/test_atom.py index a33732c26..f3e6a770c 100644 --- a/libcst/_nodes/tests/test_atom.py +++ b/libcst/_nodes/tests/test_atom.py @@ -240,14 +240,14 @@ class AtomTest(CSTNodeTest): "parser": parse_expression, "expected_position": CodeRange((1, 1), (1, 7)), }, - # Simple elipses + # Simple ellipses { "node": cst.Ellipsis(), "code": "...", "parser": parse_expression, "expected_position": None, }, - # Parenthesized elipses + # Parenthesized ellipses { "node": cst.Ellipsis(lpar=(cst.LeftParen(),), rpar=(cst.RightParen(),)), "code": "(...)", diff --git a/libcst/_nodes/tests/test_comparison.py b/libcst/_nodes/tests/test_comparison.py index d4b985c78..bb207619c 100644 --- a/libcst/_nodes/tests/test_comparison.py +++ b/libcst/_nodes/tests/test_comparison.py @@ -310,7 +310,7 @@ def test_valid( ), "at least one space around comparison operator", ), - # whitespace around the comparision itself + # whitespace around the comparison itself # a ifb > c else d ( lambda: cst.IfExp( diff --git a/libcst/_nodes/tests/test_ifexp.py b/libcst/_nodes/tests/test_ifexp.py index dd260ef34..d5cdad314 100644 --- a/libcst/_nodes/tests/test_ifexp.py +++ b/libcst/_nodes/tests/test_ifexp.py @@ -15,7 +15,7 @@ class IfExpTest(CSTNodeTest): @data_provider( ( - # Simple if experessions + # Simple if expressions ( cst.IfExp( body=cst.Name("foo"), test=cst.Name("bar"), orelse=cst.Name("baz") diff --git a/libcst/_nodes/tests/test_yield.py b/libcst/_nodes/tests/test_yield.py index e5085b4d8..2cfe9cc29 100644 --- a/libcst/_nodes/tests/test_yield.py +++ b/libcst/_nodes/tests/test_yield.py @@ -116,7 +116,7 @@ def test_valid( ), "Must have at least one space after 'yield' keyword", ), - # MAke sure we have adequate space after from + # Make sure we have adequate space after from ( lambda: cst.Yield( cst.From( diff --git a/libcst/_nodes/whitespace.py b/libcst/_nodes/whitespace.py index b1332c132..f22f14f60 100644 --- a/libcst/_nodes/whitespace.py +++ b/libcst/_nodes/whitespace.py @@ -70,7 +70,7 @@ class SimpleWhitespace(BaseParenthesizableWhitespace, BaseValueToken): expression between two tokens. This is the most common type of whitespace. A simple whitespace cannot contain a newline character unless it is directly - preceeded by a line continuation character (``\\``). It can contain zero or + preceded by a line continuation character (``\\``). It can contain zero or more spaces or tabs. If you need a newline character without a line continuation character, use :class:`ParenthesizedWhitespace` instead. @@ -291,6 +291,6 @@ def empty(self) -> bool: :class:`ParenthesizedWhitespace` this will always be ``False``. """ - # Its not possible to have a ParenthesizedWhitespace with zero characers. + # Its not possible to have a ParenthesizedWhitespace with zero characters. # If we did, the TrailingWhitespace would not have parsed. return False diff --git a/libcst/_parser/conversions/expression.py b/libcst/_parser/conversions/expression.py index 79d7ad783..980c84098 100644 --- a/libcst/_parser/conversions/expression.py +++ b/libcst/_parser/conversions/expression.py @@ -897,7 +897,7 @@ def convert_atom_basic( ) else: raise ParserSyntaxError( - f"Unparseable number {child.string}", + f"Unparsable number {child.string}", lines=config.lines, raw_line=0, raw_column=0, diff --git a/libcst/_parser/conversions/statement.py b/libcst/_parser/conversions/statement.py index f96c6ea21..eeb656ba2 100644 --- a/libcst/_parser/conversions/statement.py +++ b/libcst/_parser/conversions/statement.py @@ -1085,7 +1085,7 @@ def convert_asyncable_funcdef(config: ParserConfig, children: Sequence[Any]) -> def convert_funcdef(config: ParserConfig, children: Sequence[Any]) -> Any: defnode, namenode, param_partial, *annotation, colon, suite = children - # If the trailing paremeter doesn't have a comma, then it owns the trailing + # If the trailing parameter doesn't have a comma, then it owns the trailing # whitespace before the rpar. Otherwise, the comma owns it (and will have # already parsed it). We don't check/update ParamStar because if it exists # then we are guaranteed have at least one kwonly_param. diff --git a/libcst/_parser/parso/pgen2/generator.py b/libcst/_parser/parso/pgen2/generator.py index 5e83741bd..c31d3bd13 100644 --- a/libcst/_parser/parso/pgen2/generator.py +++ b/libcst/_parser/parso/pgen2/generator.py @@ -80,7 +80,7 @@ def __init__(self, from_rule: str, nfa_set: Set[NFAState], final: NFAState) -> N self.nonterminal_arcs: Mapping[str, DFAState] = {} # Transitions are basically the only thing that the parser is using - # with is_final. Everyting else is purely here to create a parser. + # with is_final. Everything else is purely here to create a parser. self.transitions: Mapping[Union[_TokenTypeT, ReservedString], DFAPlan] = {} self.is_final = final in nfa_set diff --git a/libcst/_parser/parso/python/tokenize.py b/libcst/_parser/parso/python/tokenize.py index 711a87857..23d8934a5 100644 --- a/libcst/_parser/parso/python/tokenize.py +++ b/libcst/_parser/parso/python/tokenize.py @@ -100,7 +100,7 @@ def different_case_versions(prefix): yield "".join(s) # The valid string prefixes. Only contain the lower case versions, - # and don't contain any permuations (include 'fr', but not + # and don't contain any permutations (include 'fr', but not # 'rf'). The various permutations will be generated. valid_string_prefixes = ["b", "r"] if version_info >= (3, 0): diff --git a/libcst/_parser/whitespace_parser.py b/libcst/_parser/whitespace_parser.py index 1c29efc5d..fc6df80af 100644 --- a/libcst/_parser/whitespace_parser.py +++ b/libcst/_parser/whitespace_parser.py @@ -5,7 +5,7 @@ """ Parso doesn't attempt to parse (or even emit tokens for) whitespace or comments that -aren't syntatically important. Instead, we're just given the whitespace as a "prefix" of +aren't syntactically important. Instead, we're just given the whitespace as a "prefix" of the token. However, in our CST, whitespace is gathered into far more detailed objects than a simple diff --git a/libcst/codegen/gather.py b/libcst/codegen/gather.py index 5eeaa7d33..481980bc4 100644 --- a/libcst/codegen/gather.py +++ b/libcst/codegen/gather.py @@ -15,7 +15,7 @@ def _get_bases() -> Iterator[Type[cst.CSTNode]]: """ Get all base classes that are subclasses of CSTNode but not an actual - node itself. This allows us to keep our types sane by refering to the + node itself. This allows us to keep our types sane by referring to the base classes themselves. """ diff --git a/libcst/codemod/_cli.py b/libcst/codemod/_cli.py index d9c70d055..3a1868c9a 100644 --- a/libcst/codemod/_cli.py +++ b/libcst/codemod/_cli.py @@ -551,7 +551,7 @@ def parallel_exec_transform_with_prettyprint( # noqa: C901 binary. A progress indicator as well as any generated warnings will be printed to stderr. To - supress the interactive progress indicator, set ``hide_progress`` to ``True``. Files + suppress the interactive progress indicator, set ``hide_progress`` to ``True``. Files that include the generated code marker will be skipped unless the ``include_generated`` parameter is set to ``True``. Similarly, files that match a supplied blacklist of regex patterns will be skipped. Warnings for skipping both diff --git a/libcst/codemod/_command.py b/libcst/codemod/_command.py index b7784d305..bc33697e0 100644 --- a/libcst/codemod/_command.py +++ b/libcst/codemod/_command.py @@ -36,7 +36,7 @@ class CodemodCommand(Codemod, ABC): - :class:`~libcst.codemod.visitors.RemoveImportsVisitor` (removes unreferenced imports from a module). """ - #: An overrideable description attribute so that codemods can provide + #: An overridable description attribute so that codemods can provide #: a short summary of what they do. This description will show up in #: command-line help as well as when listing available codemods. DESCRIPTION: str = "No description." diff --git a/libcst/codemod/_runner.py b/libcst/codemod/_runner.py index 4e76a9357..6e22d81c2 100644 --- a/libcst/codemod/_runner.py +++ b/libcst/codemod/_runner.py @@ -128,7 +128,7 @@ def transform_module( the reason for skipping as well as any warnings that were generated before the codemod decided to skip. If the codemod throws an unexpected exception, this will return a :class:`~libcst.codemod.TransformFailure` containing the - exception that occured as well as any warnings that were generated before the + exception that occurred as well as any warnings that were generated before the codemod crashed. """ try: diff --git a/libcst/codemod/commands/add_trailing_commas.py b/libcst/codemod/commands/add_trailing_commas.py index 2f33a4bd7..d055bb451 100644 --- a/libcst/codemod/commands/add_trailing_commas.py +++ b/libcst/codemod/commands/add_trailing_commas.py @@ -69,7 +69,7 @@ def add_args(arg_parser: argparse.ArgumentParser) -> None: default="black", ) arg_parser.add_argument( - "--paramter-count", + "--parameter-count", dest="parameter_count", metavar="PARAMETER_COUNT", help="Minimal number of parameters for us to add trailing comma", diff --git a/libcst/codemod/commands/convert_type_comments.py b/libcst/codemod/commands/convert_type_comments.py index 5863d94bf..d91cc56f3 100644 --- a/libcst/codemod/commands/convert_type_comments.py +++ b/libcst/codemod/commands/convert_type_comments.py @@ -107,7 +107,7 @@ def _is_type_comment(comment: Optional[cst.Comment]) -> bool: Unfortunately, to strip type comments in a location-invariant way requires finding them from pure libcst data. We only use this in function defs, where - the precise cst location of the type comment cna be hard to predict. + the precise cst location of the type comment can be hard to predict. """ if comment is None: return False @@ -623,7 +623,7 @@ def leave_For( ) except _ArityError: return updated_node - # There is no arity error, so we can add the type delaration(s) + # There is no arity error, so we can add the type declaration(s) return cst.FlattenSentinel( [ *type_declarations, @@ -674,7 +674,7 @@ def leave_With( ) except _ArityError: return updated_node - # There is no arity error, so we can add the type delaration(s) + # There is no arity error, so we can add the type declaration(s) return cst.FlattenSentinel( [ *type_declarations, diff --git a/libcst/codemod/commands/fix_variadic_callable.py b/libcst/codemod/commands/fix_variadic_callable.py index 85cb0aa08..97c571cc4 100644 --- a/libcst/codemod/commands/fix_variadic_callable.py +++ b/libcst/codemod/commands/fix_variadic_callable.py @@ -11,7 +11,7 @@ from libcst.metadata import QualifiedName, QualifiedNameProvider, QualifiedNameSource -class FixVariadicCallableCommmand(VisitorBasedCodemodCommand): +class FixVariadicCallableCommand(VisitorBasedCodemodCommand): DESCRIPTION: str = ( "Fix incorrect variadic callable type annotations from `Callable[[...], T]` to `Callable[..., T]``" ) diff --git a/libcst/codemod/commands/tests/test_convert_type_comments.py b/libcst/codemod/commands/tests/test_convert_type_comments.py index 2c5917d14..b9b251bba 100644 --- a/libcst/codemod/commands/tests/test_convert_type_comments.py +++ b/libcst/codemod/commands/tests/test_convert_type_comments.py @@ -208,7 +208,7 @@ def test_no_change_when_type_comment_unused(self) -> None: # a commented type comment (per PEP 484) is not a type comment z = 15 # # type: int - # ignore unparseable type comments + # ignore unparsable type comments var = "var" # type: this is not a python type! # a type comment in an illegal location won't be used @@ -255,7 +255,7 @@ class TestConvertTypeComments_FunctionDef(TestConvertTypeCommentsBase): and is well-covered by TestConvertTypeComments_AssignForWith, so we can stick to just simple builtin types. - The application of types is independent of where they came from. - - Type comment removal is indepenent of type application, other + - Type comment removal is independent of type application, other than in the case where we give up entirely. - The rules for which type gets used (existing annotation, inline comment, or func type comment) is independent of the location of a parameter. @@ -419,7 +419,7 @@ def test_no_change_if_function_type_comments_unused(self) -> None: def f(x, y): # type: (int) -> float pass - # unparseable function type + # unparsable function type def f(x, y): # type: this is not a type! pass diff --git a/libcst/codemod/commands/tests/test_fix_variadic_callable.py b/libcst/codemod/commands/tests/test_fix_variadic_callable.py index 848f0c98c..57fa69003 100644 --- a/libcst/codemod/commands/tests/test_fix_variadic_callable.py +++ b/libcst/codemod/commands/tests/test_fix_variadic_callable.py @@ -6,11 +6,11 @@ # pyre-strict from libcst.codemod import CodemodTest -from libcst.codemod.commands.fix_variadic_callable import FixVariadicCallableCommmand +from libcst.codemod.commands.fix_variadic_callable import FixVariadicCallableCommand -class TestFixVariadicCallableCommmand(CodemodTest): - TRANSFORM = FixVariadicCallableCommmand +class TestFixVariadicCallableCommand(CodemodTest): + TRANSFORM = FixVariadicCallableCommand def test_callable_typing(self) -> None: before = """ diff --git a/libcst/codemod/commands/tests/test_rename.py b/libcst/codemod/commands/tests/test_rename.py index 5b6e01286..e41e8670b 100644 --- a/libcst/codemod/commands/tests/test_rename.py +++ b/libcst/codemod/commands/tests/test_rename.py @@ -417,7 +417,7 @@ class Foo(a.z): new_name="d.baz", ) - def test_other_import_froms_untouched(self) -> None: + def test_other_import_forms_untouched(self) -> None: before = """ from a import b, c, d diff --git a/libcst/codemod/visitors/_apply_type_annotations.py b/libcst/codemod/visitors/_apply_type_annotations.py index 593474204..4e9300082 100644 --- a/libcst/codemod/visitors/_apply_type_annotations.py +++ b/libcst/codemod/visitors/_apply_type_annotations.py @@ -126,7 +126,7 @@ def _find_generic_base( @dataclass(frozen=True) class FunctionKey: """ - Class representing a funciton name and signature. + Class representing a function name and signature. This exists to ensure we do not attempt to apply stubs to functions whose definition is incompatible. @@ -619,7 +619,7 @@ def any_changes_applied(self) -> bool: class ApplyTypeAnnotationsVisitor(ContextAwareTransformer): """ - Apply type annotations to a source module using the given stub mdules. + Apply type annotations to a source module using the given stub modules. You can also pass in explicit annotations for functions and attributes and pass in new class definitions that need to be added to the source module. diff --git a/libcst/codemod/visitors/_remove_imports.py b/libcst/codemod/visitors/_remove_imports.py index b625ee602..a0445209a 100644 --- a/libcst/codemod/visitors/_remove_imports.py +++ b/libcst/codemod/visitors/_remove_imports.py @@ -235,7 +235,7 @@ def remove_unused_import_by_node( under modification with an instance of this class after performing your transform. Note that all imports that are referenced by this ``node`` or its children will only be removed if they are not in use at the time - of exeucting :meth:`~libcst.codemod.Codemod.transform_module` + of executing :meth:`~libcst.codemod.Codemod.transform_module` on an instance of :class:`~libcst.codemod.visitors.AddImportsVisitor` in order to avoid removing an in-use import. """ diff --git a/libcst/codemod/visitors/tests/test_add_imports.py b/libcst/codemod/visitors/tests/test_add_imports.py index 613da9071..20532af5f 100644 --- a/libcst/codemod/visitors/tests/test_add_imports.py +++ b/libcst/codemod/visitors/tests/test_add_imports.py @@ -1002,7 +1002,7 @@ def test_do_not_add_existing(self) -> None: def test_add_existing_at_top(self) -> None: """ - Should add new import at exisitng from import at top + Should add new import at existing from import at top """ before = """ diff --git a/libcst/codemod/visitors/tests/test_apply_type_annotations.py b/libcst/codemod/visitors/tests/test_apply_type_annotations.py index e7b251240..5cc5b66be 100644 --- a/libcst/codemod/visitors/tests/test_apply_type_annotations.py +++ b/libcst/codemod/visitors/tests/test_apply_type_annotations.py @@ -232,7 +232,7 @@ def foo(x: str) -> str: pass """, ), - "param_with_existng_return": ( + "param_with_existing_return": ( """ def foo(x: int) -> int: ... """, @@ -604,7 +604,7 @@ def incomplete_stubs_with_stars( # happen to align well, but none of these cases are guaranteed to work # in general - for example duplicate type names will generally result in # incorrect codemod. - "REQURIES_PREEXISTING_new_import_okay_if_existing_aliased": ( + "REQUIRES_PREEXISTING_new_import_okay_if_existing_aliased": ( """ def foo() -> b.b.A: ... """, @@ -637,7 +637,7 @@ def foo() -> db.Connection: return db.Connection() """, ), - "REQURIRES_PREEXISTING_fully_qualified_typing": ( + "REQUIRES_PREEXISTING_fully_qualified_typing": ( """ def foo() -> typing.Sequence[int]: ... """, diff --git a/libcst/display/text.py b/libcst/display/text.py index 0e2700096..f5084504a 100644 --- a/libcst/display/text.py +++ b/libcst/display/text.py @@ -109,7 +109,7 @@ def dump( ) -> str: """ Returns a string representation of the node that contains minimal differences - from the default contruction of the node while also hiding whitespace and + from the default construction of the node while also hiding whitespace and syntax fields. Setting ``show_defaults`` to ``True`` will add fields regardless if their @@ -120,7 +120,7 @@ def dump( ``show_defaults``. When all keyword args are set to true, the output of this function is - indentical to the __repr__ method of the node. + identical to the __repr__ method of the node. """ return "".join( _node_repr_recursive( diff --git a/libcst/helpers/tests/test_template.py b/libcst/helpers/tests/test_template.py index cef82dde5..1c961e699 100644 --- a/libcst/helpers/tests/test_template.py +++ b/libcst/helpers/tests/test_template.py @@ -283,7 +283,7 @@ def test_suite(self) -> None: def test_subscript(self) -> None: # Test that we can insert various subscript slices into an - # acceptible spot. + # acceptable spot. expression = parse_template_expression( "Optional[{type}]", type=cst.Name("int"), diff --git a/libcst/matchers/_matcher_base.py b/libcst/matchers/_matcher_base.py index 1727f0df5..20e2c09be 100644 --- a/libcst/matchers/_matcher_base.py +++ b/libcst/matchers/_matcher_base.py @@ -101,7 +101,7 @@ def __invert__(self: _BaseMatcherNodeSelfT) -> "_BaseMatcherNodeSelfT": def DoNotCare() -> DoNotCareSentinel: """ Used when you want to match exactly one node, but you do not care what node it is. - Useful inside sequences such as a :class:`libcst.matchers.Call`'s args attribte. + Useful inside sequences such as a :class:`libcst.matchers.Call`'s args attribute. You do not need to use this for concrete matcher attributes since :func:`DoNotCare` is already the default. @@ -128,7 +128,7 @@ class TypeOf(Generic[_MatcherTypeT], BaseMatcherNode): (m.BinaryOperation | m.BooleanOperation)(left = m.Name("foo")) - Also :class:`TypeOf` matchers can be used with initalizing in the default + Also :class:`TypeOf` matchers can be used with initializing in the default state of other node matchers (without passing any extra patterns):: m.Name | m.SimpleString @@ -142,21 +142,21 @@ def __init__(self, *options: Union[_MatcherTypeT, "TypeOf[_MatcherTypeT]"]) -> N actual_options: List[_MatcherTypeT] = [] for option in options: if isinstance(option, TypeOf): - if option.initalized: + if option.initialized: raise ValueError( - "Cannot chain an uninitalized TypeOf with an initalized one" + "Cannot chain an uninitialized TypeOf with an initialized one" ) actual_options.extend(option._raw_options) else: actual_options.append(option) - self._initalized = False + self._initialized = False self._call_items: Tuple[Tuple[object, ...], Dict[str, object]] = ((), {}) self._raw_options: Tuple[_MatcherTypeT, ...] = tuple(actual_options) @property - def initalized(self) -> bool: - return self._initalized + def initialized(self) -> bool: + return self._initialized @property def options(self) -> Iterator[BaseMatcherNode]: @@ -166,7 +166,7 @@ def options(self) -> Iterator[BaseMatcherNode]: yield matcher_pattern def __call__(self, *args: object, **kwargs: object) -> BaseMatcherNode: - self._initalized = True + self._initialized = True self._call_items = (args, kwargs) return self @@ -189,7 +189,7 @@ def __invert__(self) -> "AllOf[BaseMatcherNode]": def __repr__(self) -> str: types = ", ".join(repr(option) for option in self._raw_options) - return f"TypeOf({types}, initalized = {self.initalized})" + return f"TypeOf({types}, initialized = {self.initialized})" class OneOf(Generic[_MatcherT], BaseMatcherNode): @@ -552,7 +552,7 @@ class MatchMetadata(_BaseMetadataMatcher): Matcher that looks up the metadata on the current node using the provided metadata provider and compares the value on the node against the value provided to :class:`MatchMetadata`. - If the metadata provider is unresolved, a :class:`LookupError` exeption will be + If the metadata provider is unresolved, a :class:`LookupError` exception will be raised and ask you to provide a :class:`~libcst.metadata.MetadataWrapper`. If the metadata value does not exist for a particular node, :class:`MatchMetadata` will be considered not a match. @@ -634,7 +634,7 @@ class MatchMetadataIfTrue(_BaseMetadataMatcher): Matcher that looks up the metadata on the current node using the provided metadata provider and passes it to a callable which can inspect the metadata further, returning ``True`` if the matcher should be considered a match. - If the metadata provider is unresolved, a :class:`LookupError` exeption will be + If the metadata provider is unresolved, a :class:`LookupError` exception will be raised and ask you to provide a :class:`~libcst.metadata.MetadataWrapper`. If the metadata value does not exist for a particular node, :class:`MatchMetadataIfTrue` will be considered not a match. @@ -1171,7 +1171,7 @@ def _sequence_matches( # noqa: C901 if result.sequence_capture is not None: return _SequenceMatchesResult( { - # Our own match capture comes first, since we wnat to allow the same + # Our own match capture comes first, since we want to allow the same # name later in the sequence to override us. matcher.name: result.matched_nodes, **result.sequence_capture, diff --git a/libcst/matchers/_visitors.py b/libcst/matchers/_visitors.py index b92521739..308242fc6 100644 --- a/libcst/matchers/_visitors.py +++ b/libcst/matchers/_visitors.py @@ -195,7 +195,7 @@ def _verify_parameter_annotations( # each of the classes that might appear given the match string. This # can be done in the simple case by just specifying the correct cst node # type. For complex matches that use OneOf/AllOf, this could be a base class - # that encompases all possible matches, or a union. + # that encompasses all possible matches, or a union. params = [v for k, v in get_type_hints(meth).items() if k != "return"] for param in params: # Go through each possible matcher, and make sure that the annotation diff --git a/libcst/matchers/tests/test_decorators.py b/libcst/matchers/tests/test_decorators.py index 8b28657c3..3e4bc0cec 100644 --- a/libcst/matchers/tests/test_decorators.py +++ b/libcst/matchers/tests/test_decorators.py @@ -269,7 +269,7 @@ def bar() -> None: self.assertEqual(visitor.visits, ['"foo"', '"bar"', '"foobar"']) self.assertEqual(visitor.leaves, ['"foo"', '"bar"']) - def test_visit_if_inot_inside_verify_original_transform(self) -> None: + def test_visit_if_into_inside_verify_original_transform(self) -> None: # Set up a simple visitor with a call_if_inside decorator. class TestVisitor(MatcherDecoratableTransformer): def __init__(self) -> None: @@ -340,7 +340,7 @@ def bar() -> None: self.assertEqual(visitor.visits, ['"foo"', '"bar"', '"foobar"']) self.assertEqual(visitor.leaves, ['"foo"', '"bar"']) - def test_visit_if_inot_inside_verify_original_collect(self) -> None: + def test_visit_if_into_inside_verify_original_collect(self) -> None: # Set up a simple visitor with a call_if_inside decorator. class TestVisitor(MatcherDecoratableVisitor): def __init__(self) -> None: diff --git a/libcst/matchers/tests/test_matchers.py b/libcst/matchers/tests/test_matchers.py index e41bd8660..ff34baad9 100644 --- a/libcst/matchers/tests/test_matchers.py +++ b/libcst/matchers/tests/test_matchers.py @@ -730,7 +730,7 @@ def test_at_least_n_matcher_no_args_false(self) -> None: def test_zero_or_more_matcher_args_true(self) -> None: # Match a function call to "foo" where the first argument is the integer - # value 1, and the rest of the arguements are wildcards. + # value 1, and the rest of the arguments are wildcards. self.assertTrue( matches( cst.Call( @@ -748,7 +748,7 @@ def test_zero_or_more_matcher_args_true(self) -> None: ) ) # Match a function call to "foo" where the first argument is the integer - # value 1, and the rest of the arguements are integers of any value. + # value 1, and the rest of the arguments are integers of any value. self.assertTrue( matches( cst.Call( @@ -790,7 +790,7 @@ def test_zero_or_more_matcher_args_true(self) -> None: ) ) # Match a function call to "foo" where the first argument is the integer - # value 1, and the rest of the arguements are integers with the value + # value 1, and the rest of the arguments are integers with the value # 2 or 3. self.assertTrue( matches( @@ -832,7 +832,7 @@ def test_zero_or_more_matcher_args_false(self) -> None: ) ) # Fail to match a function call to "foo" where the first argument is the - # integer value 1, and the rest of the arguements are integers with the + # integer value 1, and the rest of the arguments are integers with the # value 2. self.assertFalse( matches( @@ -871,7 +871,7 @@ def test_at_least_n_matcher_args_true(self) -> None: ) ) # Match a function call to "foo" where the first argument is the integer - # value 1, and there are at least two arguements are integers of any value + # value 1, and there are at least two arguments are integers of any value # after. self.assertTrue( matches( @@ -890,7 +890,7 @@ def test_at_least_n_matcher_args_true(self) -> None: ) ) # Match a function call to "foo" where the first argument is the integer - # value 1, and there are at least two arguements that are integers with the + # value 1, and there are at least two arguments that are integers with the # value 2 or 3 after. self.assertTrue( matches( @@ -954,7 +954,7 @@ def test_at_least_n_matcher_args_false(self) -> None: ) ) # Fail to match a function call to "foo" where the first argument is the - # integer value 1, and there are at least two arguements that are integers with + # integer value 1, and there are at least two arguments that are integers with # the value 2 after. self.assertFalse( matches( diff --git a/libcst/matchers/tests/test_visitors.py b/libcst/matchers/tests/test_visitors.py index 2c059921b..1a4616d1a 100644 --- a/libcst/matchers/tests/test_visitors.py +++ b/libcst/matchers/tests/test_visitors.py @@ -446,7 +446,7 @@ def _string_leave( ): TestVisitor() - def test_bad_visit_collecter_decorator(self) -> None: + def test_bad_visit_collector_decorator(self) -> None: class TestVisitor(MatcherDecoratableVisitor): @visit(m.SimpleString()) def visit_SimpleString(self, node: cst.SimpleString) -> None: @@ -459,7 +459,7 @@ def visit_SimpleString(self, node: cst.SimpleString) -> None: ): TestVisitor() - def test_bad_leave_collecter_decorator(self) -> None: + def test_bad_leave_collector_decorator(self) -> None: class TestVisitor(MatcherDecoratableVisitor): @leave(m.SimpleString()) def leave_SimpleString( diff --git a/libcst/metadata/scope_provider.py b/libcst/metadata/scope_provider.py index 909a55b2f..e615af5c3 100644 --- a/libcst/metadata/scope_provider.py +++ b/libcst/metadata/scope_provider.py @@ -67,7 +67,7 @@ class Access: .. note:: This scope analysis only analyzes access via a :class:`~libcst.Name` or a :class:`~libcst.Name` node embedded in other node like :class:`~libcst.Call` or :class:`~libcst.Attribute`. - It doesn't support type annontation using :class:`~libcst.SimpleString` literal for forward + It doesn't support type annotation using :class:`~libcst.SimpleString` literal for forward references. E.g. in this example, the ``"Tree"`` isn't parsed as an access:: class Tree: @@ -152,7 +152,7 @@ class QualifiedName: class BaseAssignment(abc.ABC): - """Abstract base class of :class:`Assignment` and :class:`BuitinAssignment`.""" + """Abstract base class of :class:`Assignment` and :class:`BuiltinAssignment`.""" #: The name of assignment. name: str @@ -587,7 +587,7 @@ def f(self) -> "c": @property def assignments(self) -> Assignments: - """Return an :class:`~libcst.metadata.Assignments` contains all assignmens in current scope.""" + """Return an :class:`~libcst.metadata.Assignments` contains all assignments in current scope.""" return Assignments(self._assignments) @property @@ -1133,7 +1133,7 @@ def _visit_comp_alike( # This will give a "NameError: name 'x' is not defined": flat = [y for x in x for y in x] - # x isn't defined, because the first iter is evaluted outside the scope. + # x isn't defined, because the first iter is evaluated outside the scope. # This will give an UnboundLocalError, indicating that the second # comprehension's iter value is evaluated inside the scope as its elt. diff --git a/libcst/metadata/tests/test_accessor_provider.py b/libcst/metadata/tests/test_accessor_provider.py index 6ccfad5ee..f5c8e607d 100644 --- a/libcst/metadata/tests/test_accessor_provider.py +++ b/libcst/metadata/tests/test_accessor_provider.py @@ -63,6 +63,6 @@ def f(): ), ) ) - def test_accessor_provier(self, code: str) -> None: + def test_accessor_provider(self, code: str) -> None: wrapper = MetadataWrapper(cst.parse_module(dedent(code))) wrapper.visit(DependentVisitor(test=self)) diff --git a/libcst/metadata/tests/test_parent_node_provider.py b/libcst/metadata/tests/test_parent_node_provider.py index f04c10515..6a84388c3 100644 --- a/libcst/metadata/tests/test_parent_node_provider.py +++ b/libcst/metadata/tests/test_parent_node_provider.py @@ -59,6 +59,6 @@ def f(): ), ) ) - def test_parent_node_provier(self, code: str) -> None: + def test_parent_node_provider(self, code: str) -> None: wrapper = MetadataWrapper(cst.parse_module(dedent(code))) wrapper.visit(DependentVisitor(test=self)) diff --git a/libcst/tool.py b/libcst/tool.py index a2164b11e..24aa05202 100644 --- a/libcst/tool.py +++ b/libcst/tool.py @@ -210,7 +210,7 @@ def _find_and_load_config(proc_name: str) -> Dict[str, Any]: def _codemod_impl(proc_name: str, command_args: List[str]) -> int: # noqa: C901 - # Grab the configuration for running this, if it exsts. + # Grab the configuration for running this, if it exists. config = _find_and_load_config(proc_name) # First, try to grab the command with a first pass. We aren't going to react @@ -377,7 +377,7 @@ def _codemod_impl(proc_name: str, command_args: List[str]) -> int: # noqa: C901 "unified_diff", } } - # Sepcify target version for black formatter + # Specify target version for black formatter if any(config["formatter"]) and os.path.basename(config["formatter"][0]) in ( "black", "black.exe", diff --git a/native/libcst/Grammar b/native/libcst/Grammar index 274db7132..e9cdfbdea 100644 --- a/native/libcst/Grammar +++ b/native/libcst/Grammar @@ -459,7 +459,7 @@ await_primary[expr_ty] (memo): | AWAIT a=primary { CHECK_VERSION(5, "Await expressions are", _Py_Await(a, EXTRA)) } | primary primary[expr_ty]: - | invalid_primary # must be before 'primay genexp' because of invalid_genexp + | invalid_primary # must be before 'primary genexp' because of invalid_genexp | a=primary '.' b=NAME { _Py_Attribute(a, b->v.Name.id, Load, EXTRA) } | a=primary b=genexp { _Py_Call(a, CHECK(_PyPegen_singleton_seq(p, b)), NULL, EXTRA) } | a=primary '(' b=[arguments] ')' { diff --git a/native/libcst/src/nodes/expression.rs b/native/libcst/src/nodes/expression.rs index c72d301d7..2532dcf9f 100644 --- a/native/libcst/src/nodes/expression.rs +++ b/native/libcst/src/nodes/expression.rs @@ -2310,7 +2310,7 @@ impl<'a> Codegen<'a> for ConcatenatedString<'a> { #[cst_node(ParenthesizedNode, Default)] pub struct SimpleString<'a> { - /// The texual representation of the string, including quotes, prefix + /// The textual representation of the string, including quotes, prefix /// characters, and any escape characters present in the original source code, /// such as ``r"my string\n"``. pub value: &'a str, @@ -2364,7 +2364,7 @@ pub(crate) fn make_tstringtext<'r, 'a>(value: &'a str) -> DeflatedTemplatedStrin #[cst_node] pub struct TemplatedStringExpression<'a> { - // This represents the part of a t-string that is insde the brackets '{' and '}'. + // This represents the part of a t-string that is inside the brackets '{' and '}'. pub expression: Expression<'a>, pub conversion: Option<&'a str>, pub format_spec: Option>>, diff --git a/native/libcst/src/nodes/parser_config.rs b/native/libcst/src/nodes/parser_config.rs index e274d8dfb..8eeaea007 100644 --- a/native/libcst/src/nodes/parser_config.rs +++ b/native/libcst/src/nodes/parser_config.rs @@ -41,7 +41,7 @@ impl BaseWhitespaceParserConfig { impl BaseWhitespaceParserConfig { /// Equivalent to `config.lines.unwrap()[line_number - 1]`, but it return a PyErr when we get - /// an index that's out of range, instead of panicing. + /// an index that's out of range, instead of panicking. pub fn get_line(&self, line_number: usize) -> PyResult<&str> { let err_fn = || PyIndexError::new_err(format!("line number of {} is out of range", line_number)); @@ -52,7 +52,7 @@ impl BaseWhitespaceParserConfig { } /// Equivalent to `config.get_line(line_number)[column_index..]`, but it return a PyErr when - /// we get an column index that's out of range, instead of panicing. + /// we get an column index that's out of range, instead of panicking. pub fn get_line_after_column(&self, line_number: usize, column_index: usize) -> PyResult<&str> { self.get_line(line_number)? .get(column_index..) diff --git a/native/libcst/src/nodes/statement.rs b/native/libcst/src/nodes/statement.rs index d40ef3406..a96b612aa 100644 --- a/native/libcst/src/nodes/statement.rs +++ b/native/libcst/src/nodes/statement.rs @@ -98,7 +98,7 @@ pub struct IndentedBlock<'a> { /// inconsistent across a file, just not ambiguously. pub indent: Option<&'a str>, /// Any trailing comments or lines after the dedent that are owned by this indented - /// block. Statements own preceeding and same-line trailing comments, but not + /// block. Statements own preceding and same-line trailing comments, but not /// trailing lines, so it falls on :class:`IndentedBlock` to own it. In the case /// that a statement follows an :class:`IndentedBlock`, that statement will own the /// comments and lines that are at the same indent as the statement, and this diff --git a/native/libcst/src/parser/grammar.rs b/native/libcst/src/parser/grammar.rs index 868239616..e9f8830ec 100644 --- a/native/libcst/src/parser/grammar.rs +++ b/native/libcst/src/parser/grammar.rs @@ -252,23 +252,23 @@ parser! { rule import_from() -> ImportFrom<'input, 'a> = from:lit("from") dots:dots()? m:dotted_name() - import:lit("import") als:import_from_targets() { - make_import_from(from, dots.unwrap_or_default(), Some(m), import, als) + import:lit("import") also:import_from_targets() { + make_import_from(from, dots.unwrap_or_default(), Some(m), import, also) } / from:lit("from") dots:dots() - import:lit("import") als:import_from_targets() { - make_import_from(from, dots, None, import, als) + import:lit("import") also:import_from_targets() { + make_import_from(from, dots, None, import, also) } rule import_from_targets() -> ParenthesizedImportNames<'input, 'a> - = lpar:lpar() als:import_from_as_names() c:comma()? rpar:rpar() { - let mut als = als; - if let (comma@Some(_), Some(mut last)) = (c, als.last_mut()) { + = lpar:lpar() also:import_from_as_names() c:comma()? rpar:rpar() { + let mut also = also; + if let (comma@Some(_), Some(mut last)) = (c, also.last_mut()) { last.comma = comma; } - (Some(lpar), ImportNames::Aliases(als), Some(rpar)) + (Some(lpar), ImportNames::Aliases(also), Some(rpar)) } - / als:import_from_as_names() !lit(",") { (None, ImportNames::Aliases(als), None)} + / also:import_from_as_names() !lit(",") { (None, ImportNames::Aliases(also), None)} / star:lit("*") { (None, ImportNames::Star(make_importstar()), None) } rule import_from_as_names() -> Vec> @@ -304,8 +304,8 @@ parser! { #[cache] rule block() -> Suite<'input, 'a> - = n:tok(NL, "NEWLINE") ind:tok(Indent, "INDENT") s:statements() ded:tok(Dedent, "DEDENT") { - make_indented_block(n, ind, s, ded) + = n:tok(NL, "NEWLINE") ind:tok(Indent, "INDENT") s:statements() dead:tok(Dedent, "DEDENT") { + make_indented_block(n, ind, s, dead) } / s:simple_stmts() { make_simple_statement_suite(s) diff --git a/native/libcst/src/tokenizer/core/mod.rs b/native/libcst/src/tokenizer/core/mod.rs index 120b6163f..1d4a4858c 100644 --- a/native/libcst/src/tokenizer/core/mod.rs +++ b/native/libcst/src/tokenizer/core/mod.rs @@ -79,7 +79,7 @@ use crate::tokenizer::{ /// necessary, but we're keeping it to maintain compatibility. const MAX_INDENT: usize = 100; -// MAX_CHAR should be std::char::MAX once assoc_char_consts is stablized. +// MAX_CHAR should be std::char::MAX once assoc_char_consts is stabilized. // https://github.com/rust-lang/rust/issues/71763 const MAX_CHAR: char = '\u{10ffff}'; diff --git a/native/libcst/src/tokenizer/tests.rs b/native/libcst/src/tokenizer/tests.rs index 20188f47e..b650a98f5 100644 --- a/native/libcst/src/tokenizer/tests.rs +++ b/native/libcst/src/tokenizer/tests.rs @@ -45,7 +45,7 @@ fn tokenize_all<'t>( } #[test] -fn test_indentifier() { +fn test_identifier() { assert_eq!( tokenize_all("test input", &default_config()), Ok(vec![(TokType::Name, "test"), (TokType::Name, "input")]) diff --git a/native/libcst/src/tokenizer/text_position/char_width.rs b/native/libcst/src/tokenizer/text_position/char_width.rs index 10c65a41d..0cd019bee 100644 --- a/native/libcst/src/tokenizer/text_position/char_width.rs +++ b/native/libcst/src/tokenizer/text_position/char_width.rs @@ -180,7 +180,7 @@ mod tests { // beginning of text assert_eq!(cw.previous(), None); - // try going foward again + // try going forward again assert_eq!(cw.peek_character(), Some('i')); assert_eq!( cw.next(),