Commit graph

104 commits

Author SHA1 Message Date
Zsolt Dollenstein
4aa92f3857
Bump version to 1.5.1 (#1246) 2024-11-18 20:19:01 +00:00
Zsolt Dollenstein
527a4b04e1
bump versions in cargo.toml 2024-10-10 10:54:15 +01:00
dependabot[bot]
9834694730
Bump regex from 1.9.3 to 1.10.6 in /native (#1198)
Bumps [regex](https://github.com/rust-lang/regex) from 1.9.3 to 1.10.6.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.9.3...1.10.6)

---
updated-dependencies:
- dependency-name: regex
  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>
2024-08-23 10:26:36 -07:00
dependabot[bot]
ccf9623ccf
Bump trybuild from 1.0.86 to 1.0.99 in /native (#1194)
Bumps [trybuild](https://github.com/dtolnay/trybuild) from 1.0.86 to 1.0.99.
- [Release notes](https://github.com/dtolnay/trybuild/releases)
- [Commits](https://github.com/dtolnay/trybuild/compare/1.0.86...1.0.99)

---
updated-dependencies:
- dependency-name: trybuild
  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>
2024-08-22 18:47:34 -07:00
dependabot[bot]
8c5aa32000
Bump thiserror from 1.0.55 to 1.0.63 in /native (#1196)
Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.55 to 1.0.63.
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.55...1.0.63)

---
updated-dependencies:
- dependency-name: thiserror
  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>
2024-08-22 18:47:27 -07:00
dependabot[bot]
77e2a51d35
Bump peg from 0.8.1 to 0.8.4 in /native (#1197)
Bumps [peg](https://github.com/kevinmehall/rust-peg) from 0.8.1 to 0.8.4.
- [Release notes](https://github.com/kevinmehall/rust-peg/releases)
- [Commits](https://github.com/kevinmehall/rust-peg/compare/0.8.1...0.8.4)

---
updated-dependencies:
- dependency-name: peg
  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>
2024-08-22 17:42:44 -07:00
dependabot[bot]
47b171b9a7
Bump rayon from 1.7.0 to 1.10.0 in /native (#1193)
Bumps [rayon](https://github.com/rayon-rs/rayon) from 1.7.0 to 1.10.0.
- [Changelog](https://github.com/rayon-rs/rayon/blob/main/RELEASES.md)
- [Commits](https://github.com/rayon-rs/rayon/compare/rayon-core-v1.7.0...rayon-core-v1.10.0)

---
updated-dependencies:
- dependency-name: rayon
  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>
2024-08-22 17:40:50 -07:00
dependabot[bot]
38cc0798b2
Bump trybuild from 1.0.71 to 1.0.86 in /native (#1076)
Bumps [trybuild](https://github.com/dtolnay/trybuild) from 1.0.71 to 1.0.86.
- [Release notes](https://github.com/dtolnay/trybuild/releases)
- [Commits](https://github.com/dtolnay/trybuild/compare/1.0.71...1.0.86)

---
updated-dependencies:
- dependency-name: trybuild
  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>
2024-08-22 17:26:14 -07:00
dependabot[bot]
07ec61d8b0
Bump thiserror from 1.0.37 to 1.0.55 in /native (#1086)
Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.37 to 1.0.55.
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.37...1.0.55)

---
updated-dependencies:
- dependency-name: thiserror
  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>
2024-08-22 17:22:34 -07:00
dependabot[bot]
6017c40d19
Bump paste from 1.0.9 to 1.0.15 in /native (#1146)
Bumps [paste](https://github.com/dtolnay/paste) from 1.0.9 to 1.0.15.
- [Release notes](https://github.com/dtolnay/paste/releases)
- [Commits](https://github.com/dtolnay/paste/compare/1.0.9...1.0.15)

---
updated-dependencies:
- dependency-name: paste
  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>
2024-08-22 17:22:20 -07:00
dependabot[bot]
b552469f1c
Bump itertools from 0.11.0 to 0.13.0 in /native (#1150)
Bumps [itertools](https://github.com/rust-itertools/itertools) from 0.11.0 to 0.13.0.
- [Changelog](https://github.com/rust-itertools/itertools/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-itertools/itertools/compare/v0.11.0...v0.13.0)

---
updated-dependencies:
- dependency-name: itertools
  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>
2024-08-22 17:21:56 -07:00
dependabot[bot]
2e49695427
Bump memchr from 2.5.0 to 2.7.4 in /native (#1165)
Bumps [memchr](https://github.com/BurntSushi/memchr) from 2.5.0 to 2.7.4.
- [Commits](https://github.com/BurntSushi/memchr/compare/2.5.0...2.7.4)

---
updated-dependencies:
- dependency-name: memchr
  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>
2024-08-22 17:21:43 -07:00
Michel Lind
52a59471c9
Use license instead of license-file (#1189)
Per the Cargo Book, `license-file` is only to be used if a package uses
a non-standard license; see https://doc.rust-lang.org/cargo/reference/manifest.html#the-license-and-license-file-fields

Declare the licenses directly, and verify that the LICENSE file
containing the license breakdown is still included

```
…n LibCST/native/libcst_derive on  cargo-fixes [!] is 📦 v1.4.0 via 🦀 v1.77.1
⬢ [fedora:40] ❯ cargo package --list --allow-dirty | grep LICENSE
LICENSE

…n LibCST/native/libcst_derive on  cargo-fixes [!] is 📦 v1.4.0 via 🦀 v1.77.1
⬢ [fedora:40] ❯ cd ../libcst

michel in LibCST/native/libcst on  cargo-fixes [!] is 📦 v1.4.0 via 🦀 v1.77.1
⬢ [fedora:40] ❯ cargo package --list --allow-dirty | grep LICENSE
LICENSE
src/tokenizer/core/LICENSE
```

Signed-off-by: Michel Lind <salimma@fedoraproject.org>
2024-08-13 07:02:12 +01:00
Zsolt Dollenstein
fb9e47585b
make libcst_native::tokenizer public (#1182) 2024-07-31 12:13:05 +01:00
Zsolt Dollenstein
8b97600fb3
fix various Match statement visitation errors (#1161)
Fixes #1160.

This PR also

- fixes `whitespace_before_colon` being swallowed during visitation on `MatchCase`s
- adds a new type of roundtrip test that catches issues of this class: the test applies a noop transformer to exercise the visitation API and compares the result with the original source.
- adds a few more cases to the match fixture
2024-06-12 17:29:25 +01:00
Zsolt Dollenstein
96f53416e3
Bump version to 1.4.0 (#1152) 2024-05-22 10:20:33 -04:00
martin
71b0a1288b
Implement Type Defaults for Type Parameters (PEP 696) (#1141)
Co-authored-by: thereversiblewheel <martin.li@uwaterloo.ca>
2024-05-20 11:26:38 -04:00
Zsolt Dollenstein
9f54920d9d
bump version to 1.3.1 2024-04-03 21:13:08 +01:00
Zsolt Dollenstein
8b33474001
bump version to 1.3.0
Summary:

Test Plan:
2024-04-03 19:54:30 +01:00
Zsolt Dollenstein
627bb0c4ab
bump version to 1.2.0 (#1110) 2024-02-19 12:04:43 +00:00
Dimitris Iliopoulos
fa9300e3a3
Upgrade pyo3 to 0.20 (#1106)
Co-authored-by: Dimitris Iliopoulos <diliopoulos@fb.com>
2024-02-15 09:08:09 +00:00
Zsolt Dollenstein
c854c986b6
Fix parsing list matchers without explicit brackets (#1097)
```
match a:
  case 1, 2: pass
```

This is parsed correctly by the grammar, but the default values of `MatchList.lbracket` and `MatchList.rbracket` are inconsistent between Python and Rust, causing the above snippet to round-trip (from Python) to:
```
match a:
  case [1, 2]: pass
```

Fixes #1096.
2024-02-02 20:49:25 +00:00
Wilfred Hughes
c011a48a24
Allow Element::codegen to be used by external users (#1071)
The `Codegen` trait is `pub`, but users wanting to explicitly perform
codegen for `Element` had to copy-paste this part of the code.
2024-01-04 19:26:27 +00:00
David Tolnay
d97fb9be80
Update syn to v2 (#1064) 2023-12-20 15:53:54 +00:00
David Tolnay
52bbff6dfc
Set repository metadata entry for Rust crates (#1063) 2023-12-12 22:40:40 +00:00
dependabot[bot]
f8a9b80d9e
Bump rustix from 0.38.9 to 0.38.19 in /native (#1043)
Bumps [rustix](https://github.com/bytecodealliance/rustix) from 0.38.9 to 0.38.19.
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.9...v0.38.19)

---
updated-dependencies:
- dependency-name: rustix
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-18 15:07:17 -07:00
Zsolt Dollenstein
8d4229d959
bump version to 1.1.0 (#1037) 2023-10-05 19:16:12 -07:00
Zsolt Dollenstein
5df1569a40
Parse multiline expressions in f-strings (#1027) 2023-10-02 10:33:29 -07:00
Zsolt Dollenstein
face393db0
eliminate relative paths from Cargo.toml (#1031)
* eliminate relative paths from Cargo.toml

* fix paths in LICENSE files
2023-10-02 08:05:33 -07:00
Zsolt Dollenstein
03179b55eb
Parse arbitrarily nested f-strings (#1026) 2023-10-01 20:58:40 +01:00
Zsolt Dollenstein
37277e5fe7 add upper bound to pyo3 dependency 2023-09-16 04:02:14 -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
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
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
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
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
John Litborn
ea19578293
Fix crash on escaped backslashes in rf-string (#921) 2023-05-17 15:49:40 +01:00
dependabot[bot]
c016df46cd
Bump bumpalo from 3.10.0 to 3.12.0 in /native (#856)
Bumps [bumpalo](https://github.com/fitzgen/bumpalo) from 3.10.0 to 3.12.0.
- [Release notes](https://github.com/fitzgen/bumpalo/releases)
- [Changelog](https://github.com/fitzgen/bumpalo/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fitzgen/bumpalo/compare/3.10.0...3.12.0)

---
updated-dependencies:
- dependency-name: bumpalo
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-27 10:55:42 +01:00
Steven Troxler
b5c34d39a0
Fix Github issue 855 - fail to parse with statement (#861)
* Fix Github issue 855 - fail to parse with statement

When we added support for parenthesized with statements, the
grammar on the with itself was correct (it's a right and left
parenthesis around a comma-separated list of with-items, with
a possible trailing comma).

But inside of the "as" variation of the with_item rule we have a peek at
the next character, which was allowing for a comma or a colon. That peek
needs to also accept right parentheses - otherwise, if the last item
contains an `as` and has no trailing comma we fail to parse.

The bug is exercisecd by, for example, this code snippet:
```
with (foo, bar as bar,):
    pass
```

The with_wickedness test fixture has been revised to include both
the plain and async variations of this example snippet with and without
trailing comma, and tests pass after the peek rule fix.

* Add more tests covering the plain expression form of `with_item`
2023-02-16 10:49:05 -08:00
dependabot[bot]
bd4f541f2c
Bump pyo3 from 0.17.2 to 0.17.3 in /native (#805)
Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.17.2 to 0.17.3.
- [Release notes](https://github.com/pyo3/pyo3/releases)
- [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pyo3/pyo3/compare/v0.17.2...v0.17.3)

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

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-08 10:46:35 +00:00
dependabot[bot]
c105fd33ba
Bump regex from 1.6.0 to 1.7.0 in /native (#806)
Bumps [regex](https://github.com/rust-lang/regex) from 1.6.0 to 1.7.0.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.6.0...1.7.0)

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

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-08 10:46:10 +00:00
dependabot[bot]
0ef632811a
Bump once_cell from 1.15.0 to 1.16.0 in /native (#802)
Bumps [once_cell](https://github.com/matklad/once_cell) from 1.15.0 to 1.16.0.
- [Release notes](https://github.com/matklad/once_cell/releases)
- [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md)
- [Commits](https://github.com/matklad/once_cell/compare/v1.15.0...v1.16.0)

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

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-02 16:25:27 +00:00
dependabot[bot]
c606585672
Bump syn from 1.0.102 to 1.0.103 in /native (#799)
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.102 to 1.0.103.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.102...1.0.103)

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

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-02 15:38:13 +00:00