Skip to content
This repository was archived by the owner on Jul 27, 2023. It is now read-only.

Merge upstream changes for PEP695 support #27

Merged
merged 13 commits into from
Jul 17, 2023
Merged

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Jul 17, 2023

Includes the following upstream pull requests to add support for PEP 695 (type alias / generics) parsing:

Created by cherry-picking the upstreams' commits on top of our main branch e.g.

git log main..upstream/main --pretty=%h --reverse --no-merges | git cherry-pick --stdin

You can preview the commits with the --oneline flag e.g.

❯ git log main..upstream/main --reverse --no-merges --oneline --no-decorate
25b2399 Update Python ASDL for Python 3.12
df2b5df Regenerate code with latest ASDL
7b0aeee Add stub `type_params` handling for class and function definitions
30f461b Revert formatting changes to `python.rs`
3617a6c Bump size assertion for `Stmt` from 136 to 160 bytes
7516c42 Move `type_param` stubs into LALRPOP definition
d923aa9 Parse type parameters in class definitions
76a3245 Remove test for empty generic `class Foo[]: ...`
b06b266 Add test for tuple bounds
e0a8f5b Add bound to test case `test_parse_class_with_all_possible_generic_types`
3ec64e1 Consolidate tests and add coverage for trailing comma
6980037 Parse type parameters in function definitions (#96)
704eb40 Add parsing of type alias statements i.e. the `type` keyword (#97)

We should be able to preview commits that need cherry-pick in the future with an invocation like...

 git cherry main upstream/main -v

zanieb added 12 commits July 17, 2023 13:30
* Parse type parameters in function definitions
* Add test for combined items
…hon#97)

Extends RustPython#95
Closes RustPython#82

Adds parsing of new `type` soft keyword for defining type aliases.

Supports type alias statements as defined in PEP 695 e.g.

```python
type IntOrStr = int | str

type ListOrSet[T] = list[T] | set[T]

type AnimalOrVegetable = Animal | "Vegetable"

type RecursiveList[T] = T | list[RecursiveList[T]]
```

All type parameter kinds are supported as in RustPython#95.

Builds on soft keyword abstractions introduced in RustPython/RustPython#4519
@zanieb zanieb changed the title Merge upstream changes for PEP695 support (cherry-pick theirs) Merge upstream changes for PEP695 support Jul 17, 2023
@zanieb zanieb marked this pull request as ready for review July 17, 2023 18:58
Incorrectly merged LALRPOP file
@zanieb zanieb merged commit 126652b into main Jul 17, 2023
@zanieb zanieb deleted the zanie/cherry-pick-theirs branch July 17, 2023 19:49
zanieb added a commit to astral-sh/ruff that referenced this pull request Jul 18, 2023
Following astral-sh/RustPython-Parser#27 we now cherry-pick commits onto our fork instead of rebasing our fork on top of the upstream which means we do not overwrite history and a tag is not necessary to preserve the pinned commit.

In the future, we may rewrite the history in our fork. If we do, we should return to tagging the commits.
zanieb added a commit to astral-sh/ruff that referenced this pull request Jul 18, 2023
Following astral-sh/RustPython-Parser#27 we now
cherry-pick commits onto our fork instead of rebasing our fork on top of
the upstream which means we do not overwrite history and a tag is not
necessary to preserve the pinned commit.

In the future, we may rewrite the history in our fork. If we do, we
should return to tagging the commits.
evanrittenhouse pushed a commit to evanrittenhouse/ruff that referenced this pull request Jul 19, 2023
)

Following astral-sh/RustPython-Parser#27 we now
cherry-pick commits onto our fork instead of rebasing our fork on top of
the upstream which means we do not overwrite history and a tag is not
necessary to preserve the pinned commit.

In the future, we may rewrite the history in our fork. If we do, we
should return to tagging the commits.
konstin pushed a commit to astral-sh/ruff that referenced this pull request Jul 19, 2023
Following astral-sh/RustPython-Parser#27 we now
cherry-pick commits onto our fork instead of rebasing our fork on top of
the upstream which means we do not overwrite history and a tag is not
necessary to preserve the pinned commit.

In the future, we may rewrite the history in our fork. If we do, we
should return to tagging the commits.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants