Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow any expression in comprehensions' evaluated expression #936

Closed
wants to merge 5 commits into from
Closed

Commits on May 27, 2023

  1. Allow walrus in slices

    See python/cpython#23317
    
    Raised in #930.
    zsol committed May 27, 2023
    Configuration menu
    Copy the full SHA
    110109a View commit details
    Browse the repository at this point in the history
  2. 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.
    zsol committed May 27, 2023
    Configuration menu
    Copy the full SHA
    a5958d1 View commit details
    Browse the repository at this point in the history
  3. 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.
    zsol committed May 27, 2023
    Configuration menu
    Copy the full SHA
    b230302 View commit details
    Browse the repository at this point in the history
  4. 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.
    zsol committed May 27, 2023
    Configuration menu
    Copy the full SHA
    744d6fd View commit details
    Browse the repository at this point in the history

Commits on May 28, 2023

  1. 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.
    zsol committed May 28, 2023
    Configuration menu
    Copy the full SHA
    f45ba63 View commit details
    Browse the repository at this point in the history