Commit graph

1000 commits

Author SHA1 Message Date
Zsolt Dollenstein
c371cc5679
ci: update rust toolchain GHA
`actions-rs` is unmaintained
2023-12-20 16:48:29 +00:00
Zsolt Dollenstein
46060119a4
Scope provider changes for type annotations (#1014) 2023-09-30 11:16:27 +01:00
dependabot[bot]
5346bbfbdd
Bump Swatinem/rust-cache from 2.6.2 to 2.7.0 (#1020)
Bumps [Swatinem/rust-cache](https://github.com/swatinem/rust-cache) from 2.6.2 to 2.7.0.
- [Release notes](https://github.com/swatinem/rust-cache/releases)
- [Changelog](https://github.com/Swatinem/rust-cache/blob/master/CHANGELOG.md)
- [Commits](https://github.com/swatinem/rust-cache/compare/v2.6.2...v2.7.0)

---
updated-dependencies:
- dependency-name: Swatinem/rust-cache
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-30 10:20:56 +01:00
dependabot[bot]
a27c4c745c
Bump pypa/cibuildwheel from 2.15.0 to 2.16.0 (#1025)
Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.15.0 to 2.16.0.
- [Release notes](https://github.com/pypa/cibuildwheel/releases)
- [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md)
- [Commits](https://github.com/pypa/cibuildwheel/compare/v2.15.0...v2.16.0)

---
updated-dependencies:
- dependency-name: pypa/cibuildwheel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-25 09:16:01 +01:00
Zsolt Dollenstein
37277e5fe7 add upper bound to pyo3 dependency 2023-09-16 04:02:14 -07:00
Zsolt Dollenstein
9d869b6639
scope_provider: Simplify parent resolution (#1013)
This PR introduces `Scope._next_visible_parent` which deduplicates much of the logic between `_contains_in_self_or_parent`, `_find_assignment_target_parent`, and `_getitem_from_self_or_parent`.

This will be helpful when implementing scope resolution for the future `AnnotationScope`.

There should be no functionality change.
2023-09-16 03:59:29 -07:00
dependabot[bot]
b509cc8b08
Bump black from 23.7.0 to 23.9.1 (#1017)
Bumps [black](https://github.com/psf/black) from 23.7.0 to 23.9.1.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](https://github.com/psf/black/compare/23.7.0...23.9.1)

---
updated-dependencies:
- dependency-name: black
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-16 03:37:50 -07:00
dependabot[bot]
f469bcc755
Bump actions/checkout from 3 to 4 (#1015)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-16 03:36:31 -07:00
Zsolt Dollenstein
94dd20e20e
parser: remove Regexes from whitespace parser (#1008)
removing Regexes from whitespace parser allows ditching of thread local storage + lazy initialization cost

This shows a modest 2% improvement in overall parse time (inflate is improved by 10%)
2023-09-09 17:03:01 +01:00
Zsolt Dollenstein
377a292d0d
Add crate metadata 2023-09-03 18:16:11 +01:00
Micha Reiser
9c263aa897
Support files with mixed newlines (#1007)
* Add test case with mixed newlines

* Split lines by any newline character and not just by default

* Add unit test, remove copied
2023-09-02 09:56:20 +01:00
Zsolt Dollenstein
9286446f88
PEP 695 - Type Parameter Syntax (#1004)
This PR adds support for parsing and representing Type Parameters and Type Aliases as specified by PEP 695. What's missing are the scope rules, to be implemented in a future PR.

Notable (user visible) changes:

- new `TypeAlias` CST node, which is a `SmallStatement`
- new CST nodes to represent TypeVarLikes: `TypeVar`, `TypeVarTuple`, `ParamSpec`
- new helper CST nodes:  `TypeParameters` to serve as a container for multiple TypeVarLikes, and `TypeParam` which is a single item in a `TypeParameters` (owning the separating comma)
- extended `FunctionDef` and `ClassDef` with an optional `type_parameters` field, as well as `whitespace_after_type_parameters` to own the extra whitespace between type parameters and the following token
  - these new fields are added after all others to avoid breaking callers passing in fields as positional arguments
- in `FunctionDef` and `ClassDef`, `whitespace_after_name` now owns the whitespace before the type parameters if they exist
2023-08-28 22:07:22 +01:00
Zsolt Dollenstein
7c09b5d046
Remove need for regex in TextPosition::matches (#1002) 2023-08-27 16:29:20 +01:00
Zsolt Dollenstein
3bb5ba5a86
ci: test with 3.12 (#1003) 2023-08-27 16:27:38 +01:00
Zsolt Dollenstein
2064e200af
Fix readme's Python version requirement 2023-08-27 09:31:27 +01:00
Tom Forbes
75b6331d55
Switch to using thread_local regular expressions to avoid regex mutex contention (#996) 2023-08-26 15:21:05 +01:00
Tom Forbes
b28777e9e5
Remove criterion-cycles-per-byte dependency and related benchmark measurement (#995) 2023-08-26 13:34:27 +01:00
dependabot[bot]
c2d176162f
Bump Swatinem/rust-cache from 2.4.0 to 2.6.2 (#990)
Bumps [Swatinem/rust-cache](https://github.com/swatinem/rust-cache) from 2.4.0 to 2.6.2.
- [Release notes](https://github.com/swatinem/rust-cache/releases)
- [Changelog](https://github.com/Swatinem/rust-cache/blob/master/CHANGELOG.md)
- [Commits](https://github.com/swatinem/rust-cache/compare/v2.4.0...v2.6.2)

---
updated-dependencies:
- dependency-name: Swatinem/rust-cache
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-26 13:29:33 +01:00
dependabot[bot]
e9bad94d58
Bump fixit from 0.1.1 to 2.0.0.post1 (#979)
Bumps [fixit](https://github.com/Instagram/Fixit) from 0.1.1 to 2.0.0.post1.
- [Changelog](https://github.com/Instagram/Fixit/blob/main/CHANGELOG.md)
- [Commits](https://github.com/Instagram/Fixit/compare/v0.1.1...v2.0.0.post1)

---
updated-dependencies:
- dependency-name: fixit
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-26 13:07:39 +01:00
dependabot[bot]
6d11068723
Bump black from 23.3.0 to 23.7.0 (#973)
Bumps [black](https://github.com/psf/black) from 23.3.0 to 23.7.0.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](https://github.com/psf/black/compare/23.3.0...23.7.0)

---
updated-dependencies:
- dependency-name: black
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-26 13:07:12 +01:00
Zsolt Dollenstein
125f9c321b
ci: fix rust-cache config (#999) 2023-08-26 13:06:27 +01:00
Zsolt Dollenstein
cbfd9c30a3
drop support for Python 3.7 (#997) 2023-08-26 12:42:12 +01:00
Zsolt Dollenstein
43e21c8d71
ci: enable testing on windows + 3.11 (#998) 2023-08-26 12:23:13 +01:00
dependabot[bot]
b8a644bc58
Bump pypa/cibuildwheel from 2.13.0 to 2.15.0 (#987)
Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.13.0 to 2.15.0.
- [Release notes](https://github.com/pypa/cibuildwheel/releases)
- [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md)
- [Commits](https://github.com/pypa/cibuildwheel/compare/v2.13.0...v2.15.0)

---
updated-dependencies:
- dependency-name: pypa/cibuildwheel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-26 11:56:02 +01:00
Sergii Dymchenko
0f7766f451
Don't gather dirs ending .py (#994) 2023-08-26 10:54:32 +01:00
Zsolt Dollenstein
9eab2f037f
Don't insert duplicate imports (#981) 2023-07-25 16:13:48 +01:00
Zsolt Dollenstein
0fb9021218
Don't swallow trailing whitespace (#976) 2023-07-18 10:03:10 +01:00
Alessandro Pietro Bardelli
a3f5bf97d6
Allow pyo3 >=0.17 (#957) 2023-06-14 14:39:03 +01:00
Martin DeMello
50d48c1539
Do not annotate the same variable multiple times in ApplyTypeAnnotationsVisitor (#956) 2023-06-14 09:30:56 +01:00
Zsolt Dollenstein
3cacca1a10
Update changelog to 1.0.1 2023-06-07 13:26:02 +01:00
Sergii Dymchenko
203a2f5bc5
Codemod CLI: Print diff only when there is a change (#945)
Otherwise lots of empty lines are printed.
2023-06-07 12:45:53 +01:00
Zsolt Dollenstein
5eec991ef3
Fix parsing of code without trailing newlines (#940)
When the input doesn't have a trailing newline, but the last line had
exactly the amount of bytes as the current indentation level, the
tokenizer didn't emit a fake newline, causing parse errors (the grammar
expects newlines to conform with the Python spec).

I don't see any reason for fake newlines to be omitted in these cases,
so this PR removes that condition from the tokenizer.

Reported in #930.
2023-06-07 12:40:34 +01:00
Zsolt Dollenstein
2acc293347
Fix whitespace, fstring, walrus related parse errors (#939, #938, #937, #936, #935, #934, #933, #932, #931)
* Allow walrus in slices

See https://github.com/python/cpython/pull/23317

Raised in #930.

* Fix parsing of nested f-string specifiers

For an expression like `f"{one:{two:}{three}}"`, `three` is not in an f-string spec, and should be tokenized accordingly.

This PR fixes the `format_spec_count` bookkeeping in the tokenizer, so it properly decrements it when a closing `}` is encountered but only if the `}` closes a format_spec.

Reported in #930.

* Fix tokenizing `0else`

This is an obscure one.

`_ if 0else _` failed to parse with some very weird errors. It turns out that the tokenizer tries to parse `0else` as a single number, but when it encounters `l` it realizes it can't be a single number and it backtracks.

Unfortunately the backtracking logic was broken, and it failed to correctly backtrack one of the offsets used for whitespace parsing (the byte offset since the start of the line). This caused whitespace nodes to refer to incorrect parts of the input text, eventually resulting in the above behavior.

This PR fixes the bookkeeping when the tokenizer backtracks.

Reported in #930.

* Allow no whitespace between lambda keyword and params in certain cases

Python accepts code where `lambda` follows a `*`, so this PR relaxes validation rules for Lambdas.

Raised in #930.

* Allow any expression in comprehensions' evaluated expression


This PR relaxes the accepted types for the `elt` field in `ListComp`, `SetComp`, and `GenExp`, as well as the `key` and `value` fields in `DictComp`.

Fixes #500.

* Allow no space around an ifexp in certain cases

For example in `_ if _ else""if _ else _`.

Raised in #930. Also fixes #854.

* Allow no spaces after `as` in a contextmanager in certain cases

Like in `with foo()as():pass`

Raised in #930.

* Allow no spaces around walrus in certain cases

Like in `[_:=''for _ in _]`

Raised in #930.

* Allow no whitespace after lambda body in certain cases

Like in `[lambda:()for _ in _]`

Reported in #930.
2023-06-07 12:37:16 +01:00
dependabot[bot]
648e1616be
Bump usort from 1.0.6 to 1.0.7 (#946)
Bumps [usort](https://github.com/facebook/usort) from 1.0.6 to 1.0.7.
- [Changelog](https://github.com/facebook/usort/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/usort/compare/v1.0.6...v1.0.7)

---
updated-dependencies:
- dependency-name: usort
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-07 12:23:25 +01:00
Sergii Dymchenko
062bcdb07e
Fix Sentinal typo (#948) 2023-06-07 12:23:12 +01:00
John Litborn
0f78b810a4
remove quotes around charset in .editorconfig (#949) 2023-06-07 12:22:54 +01:00
dependabot[bot]
de57f7cc63
Bump pypa/cibuildwheel from 2.12.3 to 2.13.0 (#942)
Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.12.3 to 2.13.0.
- [Release notes](https://github.com/pypa/cibuildwheel/releases)
- [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md)
- [Commits](https://github.com/pypa/cibuildwheel/compare/v2.12.3...v2.13.0)

---
updated-dependencies:
- dependency-name: pypa/cibuildwheel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-01 07:25:40 +02:00
dependabot[bot]
59aeceb17e
Bump black from 23.1.0 to 23.3.0 (#918)
Bumps [black](https://github.com/psf/black) from 23.1.0 to 23.3.0.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](https://github.com/psf/black/compare/23.1.0...23.3.0)

---
updated-dependencies:
- dependency-name: black
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-26 13:44:46 +01:00
dependabot[bot]
ee80bf20e9
Update maturin requirement from <0.14,>=0.8.3 to >=0.8.3,<0.16 (#920)
Updates the requirements on [maturin](https://github.com/pyo3/maturin) to permit the latest version.
- [Release notes](https://github.com/pyo3/maturin/releases)
- [Changelog](https://github.com/PyO3/maturin/blob/main/Changelog.md)
- [Commits](https://github.com/pyo3/maturin/compare/v0.8.3...v0.15.1)

---
updated-dependencies:
- dependency-name: maturin
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-26 13:44:11 +01:00
Sigurd Ljødal
a594fe1dd2
Fix type of evaluated_value on string to allow bytes (#721)
* Fix type of evaluated_value on string

This can return bytes if the string is a bytestring, e.g.:

    In [1]: import libcst as cst

    In [2]: cst.parse_expression('b"foo"').evaluated_value
    Out[2]: b'foo'

* Fix type errors from changed signature
2023-05-26 13:43:05 +01:00
Zsolt Dollenstein
193fab4357
Switch default parser implementation to native (#929)
The old parser is now only available using LIBCST_PARSER_TYPE=pure
2023-05-25 18:24:59 +01:00
dependabot[bot]
8216b8add2
Bump Swatinem/rust-cache from 1.3.0 to 2.4.0 (#925)
Bumps [Swatinem/rust-cache](https://github.com/Swatinem/rust-cache) from 1.3.0 to 2.4.0.
- [Release notes](https://github.com/Swatinem/rust-cache/releases)
- [Changelog](https://github.com/Swatinem/rust-cache/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Swatinem/rust-cache/compare/v1.3.0...v2.4.0)

---
updated-dependencies:
- dependency-name: Swatinem/rust-cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-24 21:13:56 +01:00
Zsolt Dollenstein
bd96010782
exclude native/target directory from sdist (#928) 2023-05-24 20:36:31 +01:00
Zsolt Dollenstein
f6d87cd968 update changelog 2023-05-23 15:19:45 +01:00
Zsolt Dollenstein
858dd3d9a9 CI: add build dev dependency
This should fix the release pipeline which calls `python -m build`
2023-05-23 14:37:44 +01:00
Zsolt Dollenstein
654b14f39c
CI: bump macos version (#927)
* CI: bump macos version

* use macos-latest
2023-05-23 12:32:16 +01:00
John Litborn
38b708b5ed
relax validation rules on decorators (#926)
* relax validation on decorators

* allow any expression

---------

Co-authored-by: Zsolt Dollenstein <zsol.zsol@gmail.com>
2023-05-23 09:56:49 +01:00
John Litborn
ea19578293
Fix crash on escaped backslashes in rf-string (#921) 2023-05-17 15:49:40 +01:00
dependabot[bot]
889ce56b0f
Bump ufmt from 2.0.1 to 2.1.0 (#904)
Bumps [ufmt](https://github.com/omnilib/ufmt) from 2.0.1 to 2.1.0.
- [Release notes](https://github.com/omnilib/ufmt/releases)
- [Changelog](https://github.com/omnilib/ufmt/blob/main/CHANGELOG.md)
- [Commits](https://github.com/omnilib/ufmt/compare/v2.0.1...v2.1.0)

---
updated-dependencies:
- dependency-name: ufmt
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-25 10:00:48 +01:00
dependabot[bot]
fbfb83d3c6
Bump usort from 1.0.5 to 1.0.6 (#905)
Bumps [usort](https://github.com/facebook/usort) from 1.0.5 to 1.0.6.
- [Release notes](https://github.com/facebook/usort/releases)
- [Changelog](https://github.com/facebook/usort/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/usort/compare/v1.0.5...v1.0.6)

---
updated-dependencies:
- dependency-name: usort
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-25 09:46:32 +01:00