- @ariebovenberg made their first contribution in Instagram#605
- @sehz made their first contribution in Instagram#598
- Add docs about the native parts by @zsol in Instagram#601
- Specify minimum rust toolchain version by @zsol in Instagram#614
- build wheels on main branch for linux/arm64 by @zsol in Instagram#630
- ApplyTypeAnnotationVisitor changes
- Add support for methods with func type comment excluding self/cls by @stroxler in Instagram#622
- Merge in TypeVars and Generic base classes in ApplyTypeAnnotationVisitor by @martindemello in Instagram#596
- Full handling for applying type comments to Assign by @stroxler in Instagram#599
- Add support for For and With by @stroxler in Instagram#607
- Support FunctionDef transformations by @stroxler in Instagram#610
- change pyo3 as optional dependency in native Python Parser by @sehz in Instagram#598
- add slots to base classes, @add_slots takes bases into account by @ariebovenberg in Instagram#605
- [native] Box most enums by @zsol in Instagram#632
- [native] Return tuples instead of lists in CST nodes by @zsol in Instagram#631
- Allow trailing whitespace without newline at EOF by @zsol in Instagram#611
- Handle ast.parse failures when converting function type comments by @stroxler in Instagram#616
- [native] Don't redundantly nest StarredElement inside another Element by @isidentical in Instagram#624
- [native] Allow unparenthesized tuples inside f-strings by @isidentical in Instagram#621
- Don't require whitespace right after match by @isidentical in Instagram#628
- Proxy both parentheses in some pattern matching nodes by @isidentical in Instagram#626
This release contains a new parsing infrastructure that is turned off by default. You
can enable it by setting the LIBCST_PARSER_TYPE environment variable to native
before parsing an input with the usual LibCST APIs. Parsing Python 3.10 documents is
only supported in this new mode.
Note: the new parser is built as a native extension, so LibCST will ship with binary wheels from now on.
- Implement a Python PEG parser in Rust by @zsol in #566
- implement PEP-654: except* by @zsol in #571
- Implement PEP-634 - Match statement by @zsol in #568
- Add instructions to codegen test failures by @stroxler in #582
- Support Parenthesized With Statements by @stroxler in #584
- Support relative imports in AddImportsVisitor by @martindemello in #585
- Codemod for PEP 484 Assign w / type comments -> PEP 526 AnnAssign by @stroxler in #594
- Update license headers by @zsol in #560
- Use precise signature matching when inserting function type annotations by @martindemello in #591
- Fix missing string annotation references #561
- Add --indent-string option to
libcst.tool print#525 - Publish pre-release packages to test.pypi.org #550
- Add ImportAssignment class extending Assignment to record assignments for import statements #554
- Various documentation fixes #527, #529
- Do not add imports if we added no type info in ApplyTypeAnnotationVisitor (commit)
- Support relative imports in ApplyTypeAnnotationVisitor qualifier handling #538
- Don't gather metadata if the wrapper already contains it #545
- Swallow parsing errors in string annotations #548
- Stop parsing string annotations when no longer in a typing call #546
- Move find_qualified_names_for in the Assignment class #557
- Fix pyre command for type inference provider #523
- Change codegen to treat typing.Union[Foo, NoneType] and typing.Optional[Foo] as the same [#508]((Instagram#508)
- Rewrite the MatchIfTrue type to be generic on _MatchIfTrueT #512
- Add python3.9 to the CI #506
- Various CI changes #471 #510 #505 #515 #516
- Don't reset subprocess environment to fix codemodding on windows #495
- TypeAnnotationsVisitor: don't truncate function return type #499
- Docs: Fix typo #492
- Return more specific QNames for assignments #477
- Tie accesses from string annotation to the string node #483
- Fix leaking processes from TypeInferenceProvider #474
- Fix TypeInferenceProvider breakage with empty cache #476
- Fix formatting for link to QualifiedName class in docs #480
- Add FlattenSentinel to support replacing a statement with multiple statements #455
- Add BuiltinScope #469
- Add FullyQualifiedNameProvider #465
- Split QualifiedNameProvider out from libcst.metadata.scope_provider #464
- Exception while parsing escape character in raw f-strings #462
- Optimization: reduce the number of unused parallel processes #440
- Walrus operator's left hand side now has STORE expression context #443
- ApplyTypeAnnotationsVisitor applies parameter annotations even if no return type is declared #445
- Work around Windows problem by using dummy pool for
jobs=1#436 - Remove extra unused imports added in other files #453
- Support PEP-604 style unions in decorator annotations #429
- Gathering exports in augmented assignment statements #426
- Don't allow out of order accesses in the global scope #431
- Handle scope ordering in For statements #430
- Fix for not parsing subscripts such as
cast()["from"]#428 - Walrus operator's left hand side now has STORE expression context #433
- Support Named Unicode Characters and yield in f-strings #424
- Fix is_annotation for types used in classdef base and assign value #406
- Visit concatenated f-strings during scope analysis #411
- Correct handling of walrus operator in function args #417
- Allow generator expressions in f-strings #419
- Keep track of assignment/access ordering during scope analysis #413
- Handle string type references in cast() during scope analysis #418
- Use correct type for AugAssign and AnnAssign target #396
- Support string annotations for type aliases #401
- fix RemoveImportsVisitor crash when ImportAlias is inserted without comma #397
- Provide STORE for {Class,Function}Def.name in ExpressionContextProvider #394
- Implement TypeOf matcher #384
- Update return type of ParentNodeProvider to be CSTNode #377
- Add source code links to each class/function #378
- Removing an import alias with a trailing standalone comment should preserve the comment #392
- Handle string annotations in ScopeProvider #373
- Add is_annotation subtype for Access inreferences. #372
- Call pyre query with noninteractive logging #371
- Replace matchers with explicit visitation in gatherers #366
- Include missing test data in install #365
- Spaces around walrus operator are not required #368
- SaveMachedNode now matches with trailing empty wildcards #356
- Correctly extract wildcard matchers #355
- Support string type annotations in RemoveUnusedImports #353
- Add scope to ImportAlias #350
- Add scope to ClassDef #349
- Handle type subscripts when applying annotations. #335
- Added FullRepoManager
cacheproperty #330 - Added optional args for tox commands #327
- Only remove trailing comma if the last alias is removed #334
- Fixed inserting imports after module docstring #343
- Fixed ParenthesizedWhitespace before params in FuncDef #342
- Fixed validation for ImportAlias and Try statements #340
- Fixed NotEqual position issue #325
- Fixed minor typo in scope_provider.py #324
- Added
RenameCommandto rename all instances of a local or imported object to a specified new name. #308
- Fixed
ImportErrorunder Python 3.9. #306 - Fixed
stdoutbeing plugged into successfully codemod-ed files. #309 - Fixed
QualifiedNameretrieval for names with repeated substrings. #312 - Fixed default values of keyword-only and positional-only arguments in
ApplyTypeAnnotationsVisitor. #314 - Fixed
ExpressionContextProviderby giving subscript values aLOADcontext. #319
- Added
ConvertNamedTupleToDataclassCommandto convertNamedTupleclass declarations to Python 3.7dataclassesusing the@dataclass(frozen=True)decorator. #299
- Fixed typo in file name
libcst/codemod/commands/convert_percent_format_to_fstring.py. #301 - Fixed
StopIterationexception during scope analysis matching on import names. #302
- Expose more granular
AssignmentsandAccessesfor dotted imports inScopeProvider. #284 get_qualified_names_forreturns the most appropriate qualified name. #290- Surface
SyntaxErrorraised by formatter in codemod run. #288 #289 - Rename
ApplyTypeAnnotationsVisitor.add_stub_to_contextasApplyTypeAnnotationsVisitor.store_stub_in_contextand addoverwrite_existing_annotationsto allow overwrite existing type annotations. #289
- Close opened file handles on finishing codemod to avoid
Too many open fileson OSX. #283
ApplyTypeAnnotationsVisitor.add_stub_to_contextis renamed asApplyTypeAnnotationsVisitor.store_stub_in_context.
- Supported CST parsing for Python 3.0, 3.1 and 3.3. #261
- Added
RemoveUnusedImportsCommandfor removing unused import codemod. #266 - Added
ApplyTypeAnnotationsVisitor.add_stub_to_contextfor apply type annotations from stub modules. #265
- Improved exception message of
get_metadatawhen MetadataWrapper is not used. #257 - New steps for Pyre type check in README.rst which analyzes installed Python sources for better type checking. #262
- Parsed
except(Exception):correctly while there is no space after except syntax. #256 - Fixed
RemoveImportsVisitorto not remove imports when references still exist. #264 - Fixed missing type annotations. #271
AddImportsVisitorgenerates deterministic order for added imports. #274
ByteSpanPositionProviderprovides start offset and length of CSTNode as metadata.get_docstringhelper provides docstring fromModule,ClassDefandFunctionDefnode types.
- Optimized
ScopeProviderperformance to run faster and use less memory:- remove unnecessary
Assignmentof keywordArg. - don't provide scope object for formatting information nodes.
- batch set union updates in
infer_accessesstep.
- remove unnecessary
- Fixed
_assignmentsmutation when calling read-onlyScope.get_qualified_names_forand__contains__.
- Added
RemoveImportsVisitorto remove an import if it's not used in a module. - Added
GatherExportsVisitorto gather exports specified in__all__. - Added property helpers
evaluated_nameandevaluated_nameinImportAlias. - Added helper to get full module name:
get_absolute_module_for_importandget_absolute_module_for_import_or_raise. - Added
CodemodContext.full_module_namefor full dotted module name. - Added format specifiers f-string conversion support to
ConvertFormatStringCommand.
- Moved LibCST version to
_version.pyand can print it bypython -m libcst.tool --version. - Improved
EnsureImportPresentCommandwith--aliasoption. - Improved
ConvertFormatStringCommandwith--allow-strip-commentsand--allow-awaitoptions.
- Added helpers to get both the raw and evaluated value of a SimpleString.
- Added helpers to get the quoting and prefix of SimpleString and FormattedString.
- Added a helper to get the evaluated value of number types.
- Added templated parsers for statement/expression/module to make constructing updated nodes in transforms easier.
- FullRepoManager is now integrated into codemods, so metadata requiring full repo analysis can now be used.
- Added
get_full_name_for_node_or_raisehelper to remove boilerplate of checking againstNone.
- Upgraded Pyre dependency to 0.0.41.
- Added additional status to
libcst codemodcommand. get_full_name_for_nodenow supports decorators.
- Clarified documentation around f-strings, fixed indentation.
- Fixed
libcst listcrashing if a codemod does unsafe work on import. - Fixed deploy-time dependencies so pyyaml won't have to be manually installed to execute codemods.
- QualifiedNameProvider no longer erroneously claims names inside attributes are built-ins.
- Added support for parsing and rendering Python 3.8 source code.
- Added more documentation for codemods.
- Added
get_full_name_for_expressionhelper method. - Added
has_namehelper toQualifiedNameProvider. - Added a
--python-versionflag tolibcst.tool printutility.
- Codemod command can now discover codemods in subdirectories of configured modules.
- Updgraded Pyre dependency to 0.0.39.
- Cleaned up some typos and formatting issues in comments and documentation.
- Cleaned up a few redundant typevars.
- Fixed callable typing in matchers implementation.
- Fixed incorrect base class references in matcher decorator attribute visitors.
- Fixed codemod test assertion failing for some whitespace edge cases.
- Fixed scope analysis to track variable usage on
delstatements.
- Deprecated exporting
ensure_typefromlibcstin favor oflibcst.helpers.
- Removed
ExtSliceand helper code in favor ofSubscriptElement. - Removed
default_paramsattribute onParameters. - Removed
SyntacticPositionProviderandBasicPositionProvider. - Removed
CodePositionandCodeRangeexports onlibcstin favor oflibcst.metadata.
- Command-line interface now shows rough estimate of time remaining while executing a codemod.
- Add needed import now supports import aliases.
- Added Codemod framework for running code transform over a codebase in parallel.
- Codemod for code transform logic.
- CodemodContext for preserving states across transforms.
- CodemodCommand for CLI interface.
- CodemodTest for testing codemod easily.
- yaml codemod config.
- Pre-build commands in codemod/commands/.
- Added TypeInferenceProvider for inferred type info from Pyre. A regression test suite was included.
- Added FullRepoManager for metadata inter-process cache handing.
- Fixed usage link in README.
- Fixed type annotation for Mypy compatibility.
- Upgraded Pyre to 0.0.38
- Added
extract,extractallandreplacefunctions to Matchers API.
- Fixed length restrictions for
AllOfandOneOfso that they can be used with sequence expansion operators. - Fixed batchable visitors not calling attribute visit functions.
- Fixed typos in docstrings.
- Fixed matcher type exception not being pickleable.
- Deprecated parsing function parameters with defaults into
default_paramsattribute. They can be found in theparamsattribute instead.
- Fixed broken types for sequence matchers.
- Preliminary support for 3.8 walrus operator.
- CI config and fuzz tests for 3.8.
- Experimental re-entrant codegen API.
- Added
unsafe_skip_copyoptimization toMetadataWrapper. - Matchers API now includes a
findallfunction. - Matchers now have a
MatchMetadataIfTruespecial matcher.
- Updated to latest Black release.
- Better type documentation for generated matchers.
- Clarified matchers documentation in several confusing areas.
- Drastically sped up codegen and tests.
QualifiedNamenow supports imported attributtes.ExpressionContextproperly marks loop variables asSTORE.- Various typos in documentation are fixed.
- Deprecated
BasicPositionProviderandSyntacticPositionProviderin favor ofWhitespaceInclusivePositionProviderandPositionProvider.
- Added
deep_with_changeshelper method on CSTNode. - Added metadata support to matchers.
- Added ability to get the defining node from a
LocalScope(FunctionScope,ClassScopeorComprehensionScope).
- Many changes to LibCST documentation including a new best practices page and updated scope tutorial.
- Exported
CodePositionandCodeRangefromlibcst.metadatainstead oflibcst.
- Disallowed decorating a concrete visit or leave method with
@visitor@leavedecorators. - Renamed position provider classes to be more self-explanatory.
- Fixed trailing newline detection when the last character in a file was from a continuation.
- Fixed
deep_clonepotentially blowing the stack with large LibCST trees.
- Deprecated
ExtSlicein favor ofSubscriptElement. - Deprecated parsing
Subscriptslices directly intoIndexorSlicenodes.
Scope.assignmentsandScope.accessesAPIs to access all references in a scope.- Scope analysis tutorial.
- Supported
<comprehension>inScope.get_qualified_names_forandQualifiedName. - Enforced identity equality for matchers and immutability of non-dataclass matchers.
- Generalize codegen cleanup steps for all codegen.
- Made
BatchableMetadataProvidertyping covariant over its typevar. - Fixed LICENSE header on generated matcher file.
- Cleanup unused internal noqa and on-call specification.
- Added matchers which allow comparing LibCST trees against arbitrary patterns.
- Improved tree manipulation with
deep_removeanddeep_replacehelper methods on CSTNode. - Added new metadata providers: parent node and qualified name.
- Updated Pyre to latest release.
- Updated scope metadata to provide additional helpers.
- Updated preferred method of removing a node from its parent in a visitor.
- Metadata classes and methods are now exported from "libcst.metadata" instead of several submodules.
- Fixed LICENSE file to explicitly reference individual files in the repo with different licenses.
- Fixed
deep_cloneto correctly clone leaf nodes. - Fixed all parse entrypoints to always return a tree with no duplicated leaf nodes.
- Added preliminary support for parsing Python 3.5 and Python 3.6 source.
- Added scope analysis metadata provider.
- Added mypy type support for built package.
- Several typos in documentation are fixed.
- Added attribute visitor hooks.
- Added base visit/leave methods which can be subclassed.
- Hypothesis fuzz testing suite, courtesy of Zac Hatfield-Dodds.
- Metadata documentation is much more complete.
- Fixed several whitespace validation issues caught by Hypothesis.
- Parser syntax errors are now used inside parser.
- Metadata interface is now exported.
- Dependencies are now specified with minimum revisions.
- Lots of documentation fixes.
- First public release of LibCST.
- Complete, fully typed syntax tree for Python 3.6.
- Full suite of tests for each defined node type.