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

Merge upstream changes for PEP695 support (rebase) #25

Closed
wants to merge 29 commits into from

Commits on Jul 10, 2023

  1. Configuration menu
    Copy the full SHA
    25b2399 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    df2b5df View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    7b0aeee View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    30f461b View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    3617a6c View commit details
    Browse the repository at this point in the history

Commits on Jul 11, 2023

  1. Configuration menu
    Copy the full SHA
    7516c42 View commit details
    Browse the repository at this point in the history

Commits on Jul 13, 2023

  1. Update to the latest ASDL

    Update to the latest ASDL
    MichaReiser authored Jul 13, 2023
    Configuration menu
    Copy the full SHA
    c8092b2 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d923aa9 View commit details
    Browse the repository at this point in the history
  3. Remove test for empty generic class Foo[]: ...

    Not valid syntax
    zanieb committed Jul 13, 2023
    Configuration menu
    Copy the full SHA
    76a3245 View commit details
    Browse the repository at this point in the history
  4. Add test for tuple bounds

    zanieb committed Jul 13, 2023
    Configuration menu
    Copy the full SHA
    b06b266 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    e0a8f5b View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    3ec64e1 View commit details
    Browse the repository at this point in the history

Commits on Jul 14, 2023

  1. Configuration menu
    Copy the full SHA
    c33fbee View commit details
    Browse the repository at this point in the history
  2. Parse type parameters in function definitions (RustPython#96)

    * Parse type parameters in function definitions
    * Add test for combined items
    zanieb authored Jul 14, 2023
    Configuration menu
    Copy the full SHA
    6980037 View commit details
    Browse the repository at this point in the history

Commits on Jul 17, 2023

  1. Add parsing of type alias statements i.e. the type keyword (RustPyt…

    …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
    # A non-generic type alias
    type IntOrStr = int | str
    
    # A generic type alias
    type ListOrSet[T] = list[T] | set[T]
    
    # A type alias that includes a forward reference
    type AnimalOrVegetable = Animal | "Vegetable"
    
    # A generic self-referential type alias
    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 authored Jul 17, 2023
    Configuration menu
    Copy the full SHA
    704eb40 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6c9c5eb View commit details
    Browse the repository at this point in the history
  3. Include argument parentheses in range (#5)

    # Conflicts:
    #	parser/src/parser.rs
    #	parser/src/python.rs
    #	parser/src/snapshots/rustpython_parser__parser__tests__decorator_ranges.snap
    zanieb committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    8fd4d4f View commit details
    Browse the repository at this point in the history
  4. Add Decorator node (#7)

    zanieb committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    5f241e8 View commit details
    Browse the repository at this point in the history
  5. Update snapshot tests

    zanieb committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    88238a3 View commit details
    Browse the repository at this point in the history
  6. Optimize validate_arguments (#10)

    charliermarsh authored and zanieb committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    a4388aa View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    d7d4ad4 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    96feea9 View commit details
    Browse the repository at this point in the history
  9. Add TextRange to Identifier (#8)

    This PR adds `TextRange` to `Identifier`. Right now, the AST only
    includes ranges for identifiers in certain cases (`Expr::Name`,
    `Keyword`, etc.), namely when the identifier comprises an entire AST
    node. In Ruff, we do additional ad-hoc lexing to extract identifiers
    from source code.
    
    One frequent example: given a function `def f(): ...`, we lex to find
    the range of `f`, for use in diagnostics.
    
    Another: `except ValueError as e`, for which the AST doesn't include a
    range for `e`.
    
    Note that, as an optimization, we avoid storing the `TextRange` for
    `Expr::Name`, since it's already included.
    zanieb committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    2d01070 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    dc51b89 View commit details
    Browse the repository at this point in the history
  11. Fix range of keyword identifier (#14)

    MichaReiser authored and zanieb committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    d37820a View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    e378796 View commit details
    Browse the repository at this point in the history
  13. impl<T> Ranged for &T where T: Ranged (#16)

    In the example below, `arg` is `&Expr`, so `&Ranged`, but `entries()`
    want a `T: Ranged`. This adds the missing bridge impl.
    
    ```rust
            let all_args = format_with(|f| {
                f.join_comma_separated()
                    .entries(
                        // We have the parentheses from the call so the arguments never need any
                        args.iter()
                            .map(|arg| (arg, arg.format().with_options(Parenthesize::Never))),
                    )
                    .nodes(keywords.iter())
                    .finish()
            });
    ```
    konstin authored and zanieb committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    b3a30f3 View commit details
    Browse the repository at this point in the history
  14. impl Ranged for TextRange (#20)

    This adds the missing implementation of `Ranged` for `TextRange` itself
    
    ```rust
    impl Ranged for TextRange {
        fn range(&self) -> TextRange {
            *self
        }
    }
    ```
    
    This allows e.g. using `has_comments` with arbitrary ranges instead of
    just a node.
    
    It also adds .venv to the .gitignore
    konstin authored and zanieb committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    cbd514b View commit details
    Browse the repository at this point in the history
  15. Remove asdl (#21)

    This removes the ASDL code generation in favor of handwriting the AST.
    
    The motivations for moving away from the ASDL are:
    
    * CPython compatibility is no longer a goal
    * The ASDL grammar isn't as expressive as we would like
    * The codegen scripts have a high complexity which makes extensions time
    consuming
    * We don't make heavy use of code generation (compared to e.g.
    RustPython that generates Pyo3 bindings, a fold implementation etc).
    
    We may want to revisit a grammar based code generation in the future,
    e.g. by using [ungrammar](https://github.com/rust-analyzer/ungrammar)
    konstin authored and zanieb committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    c446dde View commit details
    Browse the repository at this point in the history