Commit graph

46 commits

Author SHA1 Message Date
Zsolt Dollenstein
724026aa65
Remove reference to distutil (#1099)
Distutil has been removed in Python 3.12.

Tested by:
```
py -m libcst.tool codemod noop.NOOPCommand .\libcst\tool.py
Calculating full-repo metadata...
Executing codemod...
Finished codemodding 1 files!
 - Transformed 1 files successfully.
 - Skipped 0 files.
 - Failed to codemod 0 files.
 - 0 warnings were generated.
```
2024-02-02 20:58:56 +00:00
Zsolt Dollenstein
738dc2f893
Upgrade pyre (#1032)
* Upgrade pyre

* regen fixtures
2023-10-02 09:43:17 -07:00
Aarni Koskela
4f810dbc13
Allow running codemods without configuring in YAML (#879)
* Simplify command specifier parsing

* Allow running codemods without configuring in YAML

This enables codemodding things by just plonking a CodemodCommand class
into any old importable module and running
`python -m libcst.tool codemod -x some_module.SomeClass ...`
2023-03-27 10:59:48 +01:00
dependabot[bot]
46509dd5e1
Bump black from 22.12.0 to 23.1.0 (#860) 2023-03-15 11:53:50 +00:00
MapleCCC
667c713b38
Fix the bug that the use of formatter in codemods has undetermined target Python version, resulting in hard-to-reason-with behavior (#771)
* When codemod, specify the black formatter to use the same target Python version we use

* Fix the `test_codemod_formatter_error_input` unit test

* Remove an unused import in `test_codemod_cli` module
2022-09-14 14:31:36 +01:00
Zsolt Dollenstein
c44ff0500b
Fix license headers (#560)
* Facebook -> Meta

* remove year from doc copyright
2021-12-28 11:55:18 +00:00
John Reese
10c3aa09a7
Upgrade to µsort 1.0.0rc1, and apply formatting changes (#565)
* Upgrade to usort==1.0.0rc1

* Apply sorting changes from usort 1.0.0rc1

* reapply codegen

Co-authored-by: Zsolt Dollenstein <zsol.zsol@gmail.com>
2021-12-21 14:55:04 -08:00
John Reese
71b8002cca
Add --indent-string option to libcst.tool print (#525)
Allows passing a custom indent string, like ".   ", for easier visual
parsing of the resulting tree.
2021-09-28 09:47:12 -07:00
Steven Troxler
5e1e3fe970
The ufmt tool combines usort and black with a consistent wrapper, (#515)
which ensures we won't have inconsistent black-vs-isort errors
going forward. We can always format by running `ufmt format .`
at the root, and check with `ufmt check .` in our CI actions.
2021-08-25 20:39:29 -04:00
Luke Petre
1c3a27bbd5
Add Github Actions and derive version from git tags (#471)
* Use setuptools-scm to derive the current version from git metadata

* Add Github Action equivalent to the current circleci tasks

* Run pyre integration test in GH action / tox
2021-08-10 15:01:16 +01:00
jimmylai
c023fa7c4c
[typing] enable Pyre strict mode by default (#313)
Co-authored-by: Jimmy Lai <jimmylai@fb.com>
2020-06-12 18:24:18 -07:00
Jennifer Taylor
f6a1c77b2a Add a --version flag to libcst.tool, single-source version. 2020-02-07 11:51:58 -08:00
Jennifer Taylor
d13be3f2e0 Integrate FullRepoManager into codemod command, allowing codemods to depend on full-repo capable metadata providers. 2020-01-28 13:45:18 -08:00
Jennifer Taylor
13c0f14c34 Fix list behavior to not crash and burn if a codemod or test tries to do something on import. 2020-01-22 13:30:46 -08:00
Jennifer Taylor
d30b04559d Implement a --python-version override flag to "libcst.tool print". 2020-01-15 17:05:33 -08:00
Jennifer Taylor
bcae954484 Add environment variable to require config file before proceeding. 2020-01-15 14:00:14 -08:00
Jennifer Taylor
6eb6ec7b1d Add posonly parameter support to Parameters node.
This is part one of a two-part change to support the posonly param indicator "/".
2020-01-15 11:18:12 -08:00
Jimmy Lai
2fb0db33d1 Clean up redundant code. 2020-01-10 08:47:21 -08:00
Jennifer Taylor
37554a85c0 Support reading arguments from file. 2020-01-09 16:05:49 -08:00
Jimmy Lai
78f0e13c48 Upgrade Pyre to 0.0.39 2020-01-09 11:06:40 -08:00
Jennifer Taylor
44afacbc67 Support codemods in subdirectories of configured modules. 2020-01-08 14:31:33 -08:00
Jennifer Taylor
9231e5ca3a Plumb through the ability to override the python version used for parsing in libcst.tool. 2019-12-19 11:40:22 -08:00
Jimmy Lai
641ad91885 apply new Black formatting 2019-12-17 14:26:38 -08:00
jimmylai
ecebaaf857
Merge branch 'master' into full_repo_manager 2019-12-16 08:40:37 -08:00
Jimmy Lai
3f2655e9ad Merge branch 'master' of github.com:Instagram/LibCST into full_repo_manager 2019-12-12 16:38:08 -08:00
Jennifer Taylor
23accb47a8 Resolve full path of formatter so that it can be found in subprocess. 2019-12-12 11:31:05 -08:00
Jennifer Taylor
9d06c3e860 Allow wrapping scripts to override the name of the command when printing tool help. 2019-12-12 11:31:05 -08:00
Jennifer Taylor
5b81857673 Change codemod command help to print out description of codemod in question if it is available. 2019-12-12 11:31:05 -08:00
Jennifer Taylor
f5c5f296fd Open-source a decent chunk of utility codemods that aren't instagram-specific. 2019-12-12 11:31:05 -08:00
Jennifer Taylor
1fcf279eed Add descriptions to all tool help, plumb tool name all the way to top level. 2019-12-12 11:31:05 -08:00
Jennifer Taylor
2f472d16b5 Add a utility to libcst.tool which can list out all available codemods in the current configuration. 2019-12-12 11:31:05 -08:00
Jennifer Taylor
196ca197c4 Add a utility to libcst.tool that can initialize a directory with a default LibCST codemod config. 2019-12-12 11:31:05 -08:00
Jennifer Taylor
9459b581f4 Add a config file format to allow customization of LibCST codemod runner. 2019-12-12 11:31:05 -08:00
Jennifer Taylor
c2900b5a39 Initial work to open-source codemod runner frontend, integrating it into libcst.tool. 2019-12-12 11:28:53 -08:00
Jennifer Taylor
93ed095c9e Fix non-unique tree generated by LibCST in some circumstances.
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.
2019-09-25 12:36:33 -07:00
Jennifer Taylor
fc430343b5 Fix internal underscore convention.
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.
2019-09-17 13:52:42 -07:00
Ray Zeng
8428ad906f Added docstring to libcst.tool.dump and reordered args to hint at their precedence 2019-08-05 16:44:19 -07:00
Jennifer Taylor
567fc1884c Refactor libcst.tool to allow for "dump" to be exported. 2019-08-05 16:44:19 -07:00
Jennifer Taylor
1190dc8a2f Import parser from the top level
This was a pain, because apparently we can't refer to
"static_analysis.libcst" as a module before its finished executing, due
to https://bugs.python.org/issue25294. To combat this, I had to change
to direct importing inside parser, which was a bit of a pain due to the
number of nodes used. But, it works.
2019-07-26 12:48:22 -07:00
Jennifer Taylor
818a7e63df Make nodes package private
Now that nodes are imported from the top level, make the nodes
directory private.
2019-07-26 12:48:22 -07:00
Jennifer Taylor
032cd49e6d Import nodes from top level instead of libcst.nodes 2019-07-26 12:48:22 -07:00
Benjamin Woodruff
46799cefcf Fix flake8 errors
This is a combination of:
- Fixing some issues upstream.
- Modifying our cleanup script to carry over noqa comments, and
  copying over the new versions of some files.
- A small addition to our flake8 config.
2019-07-22 20:05:07 -07:00
Benjamin Woodruff
670ece1e91 pyre-strict libcst/__init__.py and libcst/tool.py 2019-07-22 19:53:49 -07:00
Ray Zeng
d3544824fc Wrap _codegen methods in a helper function to track where nodes start and end.
Converts `_codegen` methods into `_codegen_impl` to wrap implementations
to calls to update the position of each node in the `CodegenState`. The
stored position is the syntactic position of a node (that includes any
whitespace attached to that particular node).

Also updates implementation of tool and `CSTNode.__repr__` to not print
fields of `CSTNode` objects prefixed with "_".
2019-07-22 19:53:49 -07:00
Jennifer Taylor
bb72c70a3b Hand-roll print instead of using implicit repr, allowing us to filter
most irrelevant node attributes out.
2019-06-05 14:25:29 -07:00
Jennifer Taylor
0719faa198 Initial export of LibCST to github. 2019-05-31 14:16:53 -07:00