Add a RemoveFromParent() function as a convenience to returning RemovalSentinel.REMOVE.
Introduce a `deep_remove()` on CSTNode analogous to `deep_replace()` but for removing.
Make explicit in the LICENSE and README files the exact files that are not licensed under MIT since being forked. These files already have license information in their headers, but it is always good to be explicit at the top level as well. Also include a copy of the licenses in the LICENSE file to conform with requirements.
We used _visit_and_replace_children to implement deep_clone, which was already
bad since it relied on the implicit behavior of _visit_and_replace_children to
make a copy on visit. If we fix that behavior in the future, deep_Clone would
have broken. However, its even more broken, because nodes that subclass from
BaseLeaf define their _visit_and_replace_children as returning self. So, not
only is this a bad coupling, but its also broken. Implement deep_clone properly
here.
When parsing, we don't always fill in defaults unless we have a good reason to. That, coupled with the fact that we use dataclasses that allow you to set a default on creation instead of runtime construction means that we accidentally aliased a whole bunch of SimpleWhitespace nodes. Fix that by switching to the datalasses field() method which allows runtime evaluation. We do this by creating a simple (untyped, unfortunately) helper on CSTNode which makes for easier creation.
This introduces a few new gotchas (namely attribute access and a bug with
Union[Callable]), but it also removes a whole host of pyre-fixmes and gets us
updated to a release of pyre that came out after May.
Standardize on the convention that private modules (those we don't expect people to directly import) are prefixed with an underscore. Everything under a directory/module that has an underscore is considered private, unless it is re-exported from a non-underscored module. Most things are exported from libcst directly, but there are a few things in libcst.tool, libcst.codegen and libcst.metadata that are namedspaced as such.
There were only grammar changes between 3.5 and 3.6, which are pretty trivial to put in. So, do that trivial bit and get us completely covered for production Python 3 versions. This could use better testing, but it is good enough as-is and we can address issues with GitHub's issue tracker.