LibCST/libcst
Benjamin Woodruff 42c3f3f267 Add an unsafe_skip_copy option to MetadataWrapper
In certain cases (e.g. inside Instagram's lint framework) we know that
our tree originates from the parser, so we know that there shouldn't be
any duplicate nodes in our tree.

MetadataWrapper exists to copy the tree ensuring that there's no
duplicate nodes.

This diff provides an escape hatch on MetadataWrapper that allows us to
save a little time and avoid a copy when we know that it's safe to skip
the copy.

As part of this, I ran into some issues with `InitVar` and pyre, so I
removed `@dataclass` from the class. This means that this is techincally
a breaking change if someone depended on the MetadataWrapper being an
actual dataclass, but I think this is unlikely. I implemented `__repr__`
and added tests for hashing/equality behavior.
2019-10-29 13:35:38 -07:00
..
_nodes Add a reentrant (incremental) codegen API 2019-10-28 17:23:26 -07:00
_parser Implement parsing of the walrus operator. 2019-10-24 15:25:21 -07:00
codegen Update black to git commit that fixes 3.8 support. 2019-10-24 15:25:21 -07:00
matchers Update matchers docs with some clarification based on user feedback. 2019-10-28 18:13:55 -07:00
metadata Add an unsafe_skip_copy option to MetadataWrapper 2019-10-29 13:35:38 -07:00
testing Bump pyre version to 0.0.30. 2019-09-25 12:04:33 -07:00
tests More explicit fuzz testing environments. 2019-10-22 17:24:03 -07:00
__init__.py Implement the walrus operator node as NamedExpr. 2019-10-24 15:25:21 -07:00
_add_slots.py Export CodePosition/CodeRange; fix pickle with add_slots 2019-07-22 20:05:07 -07:00
_batched_visitor.py Update black to git commit that fixes 3.8 support. 2019-10-24 15:25:21 -07:00
_exceptions.py Update black to git commit that fixes 3.8 support. 2019-10-24 15:25:21 -07:00
_helpers.py Add a best practices section with various recommended practices. 2019-10-23 16:50:47 -07:00
_maybe_sentinel.py Add docs for MaybeSentinel and RemovalSentinel 2019-08-08 11:04:02 -07:00
_metadata_dependent.py Make BaseMetadataProvider[T] covariant over T 2019-10-10 18:08:44 -07:00
_position.py Export CodePosition and CodeRange from metadata 2019-10-18 14:30:33 -07:00
_removal_sentinel.py Improve removing nodes from parents in LibCST. 2019-10-02 15:43:48 -07:00
_tabs.py Initial export of LibCST to github. 2019-05-31 14:16:53 -07:00
_type_enforce.py Fix flake8 errors 2019-07-22 20:05:07 -07:00
_typed_visitor.py Implement the walrus operator node as NamedExpr. 2019-10-24 15:25:21 -07:00
_typed_visitor_base.py Add codegen for visit_* and leave_* methods on CSTTransform and CSTVisitor. 2019-08-28 13:28:29 -07:00
_types.py Fix internal underscore convention. 2019-09-17 13:52:42 -07:00
_visitors.py Improve removing nodes from parents in LibCST. 2019-10-02 15:43:48 -07:00
py.typed support mypy using py.typed 2019-09-16 13:49:08 -07:00
tool.py Fix non-unique tree generated by LibCST in some circumstances. 2019-09-25 12:36:33 -07:00