Commit graph

16 commits

Author SHA1 Message Date
zaicruvoir1rominet
ca1f81f049
Avoid raising bare Exception (#1168)
* Keep old exception messages (avoid breaking-changes for users relying on exception messages)

* Move ``get_expected_str`` out of _exceptions.py, where it does not belong, to its own file in _parser/_parsing_check.py
2025-06-07 01:53:44 -07:00
Zsolt Dollenstein
2ffca10845
remove typing dependencies (#1126)
Summary:
This PR removes the `typing_extensions` and `typing_inspect` dependencies as we can now rely on the built-in `typing` module since Python 3.9.

Test Plan:
existing tests
2024-04-03 19:50:14 +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
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
Jimmy Lai
7ca738bf39
Upgrade dev tools (Black/Flake8/isort) and read install requirements from requirements.txt (#380)
* Read install requirements from requirements.txt

* read extras_require from requirements-dev.txt

* add requirements-dev.txt to MANIFEST.in

* apply fixes for new version of Black and Flake8

* don't upgrade Pyre

* re-format
2020-08-31 10:44:55 -07: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
b3253de9b8 Update black to git commit that fixes 3.8 support. 2019-10-24 15:25:21 -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
Jennifer Taylor
50c5f4ecbf Fork parso's pgen2 fork into LibCST
This completes the fork of parso into LibCST's parser directory.
2019-09-12 14:09:00 -07:00
Jennifer Taylor
34767ca6c1 Fork parso's token and tokenize modules.
Fork both of these and convert internal LibCST stuff to point at them.
Removes the TODO from previous commit now that the tokenizer is in
complete agreement.
2019-09-12 14:09:00 -07:00
Benjamin Woodruff
aac5103592 Add PartialParserSyntaxError, simplify ParserSyntaxError
Because the parser conversion functions may not understand their current
position in the code, we instead need to construct a `ParserSyntaxError`
without the current line and column information, filling it in later.

Originally I did this by allowing ParserSyntaxError to be partially
initialized, but this wasn't very type-safe, and required some ugly
assertions.

Instead, I now construct and raise a PartialParserSyntaxError. The
BaseParser class is responsible for catching that partial error object
and constructing a full ParserSyntaxError.
2019-08-22 13:35:11 -07:00
Benjamin Woodruff
7fe92e84df Improve the quality of syntax error messages
- Make INDENT/DEDENT dummy tokens more readable instead of outputting an
  empty string for them.

- Sort the "expected" list to make testing easier.

- Don't show the list of expected values if there are > 10
  possibilities. The output becomes impossible to read at that point.

- Try to avoid using an empty line for the displayed contextual line of
  source code. Instead, point at the line above it, or just don't output
  any context.
2019-08-22 13:35:11 -07:00
Benjamin Woodruff
f34d6a80fe Include ParserSyntaxError in parser documentation 2019-08-22 13:35:11 -07:00
Benjamin Woodruff
2459ba0aa0 Make ParserSyntaxError more generic (#24)
This removes the hard-coded logic about encountered/expected, and moves
it into a separate helper method.

Line and column can now be initialized lazily. We'll use this later to
raise `ParserSyntaxError`s inside of conversion functions, backfilling
the positions inside `_base_parser`, since conversion functions don't
always have access to position information.
2019-08-22 13:35:11 -07:00
Jennifer Taylor
3dec7be6ef Export things from libcst's base__init__.py
Go through and clean up where we export things from in the top level
directories. This is the first pass at cleaning up the public API. In
this diff I clean up all top-level exports that were coming out of .py
files and instead export them from libcst's base module itself.

I also didn't export a few of the things defined in newly underscored
files because they were only used internally.
2019-07-26 12:48:22 -07:00
Renamed from libcst/exceptions.py (Browse further)