Commit graph

1099 commits

Author SHA1 Message Date
Benjamin Woodruff
283a736173 Make conversion functions use ParserSyntaxError
For anything that's not an internal logic error, conversion functions
should raise a ParserSyntaxError.

Internal logic errors should probably use an AssertionError or an assert
statement, but that's not as important and is out of scope for this PR.
2019-08-22 13:35:11 -07:00
Benjamin Woodruff
e9567a08c0 Add tests to the parser for syntax errors
This tries to test all the ways a ParserSyntaxError can be thrown.
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
636cad6e6c Raise a ParserSyntaxError on mismatched braces
If we had more close braces than open braces, we used to raise an
IndexError due to an empty stack. This fixes that bug.
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
Benjamin Woodruff
2d1d2f7aa1 Add a pickle test for ParserSyntaxError
This ensures that ParserSyntaxError can safely be used with pickle, and
(by extension) multiprocessing.
2019-08-22 13:35:11 -07:00
Zac Hatfield-Dodds
2c27c0862c Fuzz with Hypothesmith 2019-08-21 17:55:28 -07:00
jimmylai
750b18c5fe
add PYPI version badge to readme (#41) 2019-08-21 11:52:57 -07:00
Jennifer Taylor
b3d5f462a5 Update changelog with new release information. 2019-08-20 16:09:15 -07:00
Jennifer Taylor
941dee9977 Bump revision number to release 0.1.1 which corrects dependencies. 2019-08-20 15:53:16 -07:00
Benjamin Woodruff
53a7c782d4 Improve PartialParserConfig's documentation
Adds details about how various configuration options can be used, and
updates some details to reflect reality (e.g. we don't currently infer
the python version from your execution environment).
2019-08-19 17:09:55 -07:00
Benjamin Woodruff
821a613c46 Raise an exception on unsupported python_version
We only support parsing code as 3.7 right now.

This raises a descriptive error message if we receive an unsupported
version number, instead of silently trying to use it with the tokenizer
and failing in potentially strange ways.
2019-08-19 17:09:55 -07:00
jimmylai
2f33bdd912
Add CodeCov badge in README 2019-08-19 13:44:52 -07:00
jimmylai
71ba5cc51d
update dependent package version in setup.py 2019-08-19 13:39:02 -07:00
jimmylai
d4dca1db5e
[CI] add test coverage run and codecov integration 2019-08-19 11:31:55 -07:00
Ray Zeng
68699e21d7 Add more examples and improve docstrings 2019-08-16 10:34:30 -07:00
Ray Zeng
e2f2eafc59 Add extended example for metadata and fix some docstrings 2019-08-16 10:34:30 -07:00
Ray Zeng
fa6bb4942c Moved metadata usage example into usage.ipynb 2019-08-16 10:34:30 -07:00
Ray Zeng
b2e26db708 resort imports 2019-08-16 10:34:30 -07:00
Ray Zeng
d91a79220b Fix some typing and improve some docstrings for metadata 2019-08-16 10:34:30 -07:00
Ray Zeng
f0b6e6c37d Re-organize metadata documentation and add a usage example 2019-08-16 10:34:30 -07:00
Ray Zeng
2e8c3b6756 Convert CodeRange.create to a constructor to clean up docs 2019-08-16 10:34:30 -07:00
Ray Zeng
63ff16cb47 Add more metadata documentation 2019-08-16 10:34:30 -07:00
Ray Zeng
79f0ebc2a4 Add sphinx docs to metadata modules 2019-08-16 10:34:30 -07:00
jimmylai
611f45e596
[doc] use original_node instead of node for consistency 2019-08-14 14:57:26 -07:00
jimmylai
08b3e48190
add link of notebook binder in README 2019-08-14 14:11:14 -07:00
Jennifer Taylor
5d1514e416 Bump version number for 0.1.dev8 release. 2019-08-12 17:27:22 -07:00
Ray Zeng
a843500b72 Update docstrings to reflect changes in API 2019-08-09 17:27:20 -07:00
Ray Zeng
27d7ce08fd Remove compatibility with old metadata API 2019-08-09 17:27:20 -07:00
Jennifer Taylor
b4967f89f6 Fix incorrect description of on_leave for CSTVisitor/CSTTransform. 2019-08-09 17:24:32 -07:00
Ray Zeng
e08e27fa30 Add tox enviroment to run isort and black and update readme 2019-08-09 10:06:29 -07:00
Ray Zeng
9602643419 Patch _MetadataDependent to not be an ABC until Pyre is fixed 2019-08-08 12:00:00 -07:00
Benjamin Woodruff
90e4efb348 Add docs for MaybeSentinel and RemovalSentinel
These were referred to by other parts of the documentation, and they
provide core parts of our functionality, so we should have explicit
documentation for them.
2019-08-08 11:04:02 -07:00
jimmylai
05c8070dfb
[readthedoc] install libcst
* [readthedoc] install libcst

* Update .readthedocs.yml
2019-08-07 15:58:02 -07:00
Benjamin Woodruff
dd22dd0361 Link to ReadTheDocs from our README file
This should make it possible for people to find our more detailed
documentation.
2019-08-07 15:03:38 -07:00
Jennifer Taylor
bf94bad977 Ignore build/ directory. 2019-08-07 14:14:35 -07:00
Benjamin Woodruff
da7b9435ee Add logo and favicon to sphinx documentation
- The white logo variant shows up on the top of the sidebar.
- The favicon shows up when the page is loaded.
2019-08-07 13:32:31 -07:00
jimmylai
1424cfb2e1
add readthedoc config file 2019-08-07 10:41:10 -07:00
Ray Zeng
da112c2f03 Don't run isort and black when running unit tests with tox 2019-08-07 09:33:47 -07:00
Benjamin Woodruff
ef0ce06e12 Remove unused sphinx plugins
It doesn't look like we need:

- `sphinx.ext.githubpages`
- `sphinx.ext.todo`
- `sphinx.ext.mathjax`

So I removed these and then sorted the list of extensions.
2019-08-06 19:39:43 -07:00
Benjamin Woodruff
ff9ed2e8e4 Change FormattedString's end field to a Literal
I noticed this while working on the documentation. I think this predated
pyre's Literal support.

I only did this for `end` and not `start`, because there's a large
combinatorial set of valid `start` values. If we wanted to better type
`start`, we should probably first separate the prefix from the opening
quotes.
2019-08-06 19:39:43 -07:00
Benjamin Woodruff
647ef53f0e Finish documentation pass over expressions
This commit mostly focuses on f-strings, collections, comprehensions,
and subscripts/slices.

I added intersphinx support to the sphinx config so I could link to
`ast.literal_eval`.

I exported BaseSimpleComp, since I felt it had some documentation value.
2019-08-06 19:39:43 -07:00
jimmylai
0839f35d55
[doc] add document to deep_clone and deep_equals
* [doc] add document to deep_clone and deep_equals

* use doctest format
2019-08-06 17:32:23 -07:00
Benjamin Woodruff
4a84389fed Allow Annotation to contain any BaseExpression
An `Annotation` can contain any `BaseExpression`, not just the short
list of types we had listed.

For example, this is valid syntax:

    val: 1 + 2 = None
2019-08-06 17:30:30 -07:00
Ray Zeng
2ba295cc01 Fix some typing issues in metadata API 2019-08-06 16:58:56 -07:00
Ray Zeng
f99cbf4c7c Fix position metadata providers and tests 2019-08-06 16:58:56 -07:00
Ray Zeng
ac595cb8f2 Rewrite metadata around module wrapper 2019-08-06 16:58:56 -07:00
Ray Zeng
69e46654d4 Rename metadata/_interface.py to metadata/dependent.py 2019-08-06 16:58:56 -07:00
Ray Zeng
21eeacc344 Add __init__ to metadata/tests 2019-08-06 16:58:56 -07:00