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

[red-knot] support fstring expressions #13511

Merged
merged 12 commits into from
Sep 27, 2024

Commits on Sep 26, 2024

  1. [red-knot] feat: support f-string expressions

    Current implementation (based on mypy behaviour):
    - evaluate any fstring with expressions as `builtin.str`
    - evaluate static fstrings (could be regular strings) as `Literal[..]`
      if it fits the max size or `LiteralString` (same as regular strings)
    Slyces committed Sep 26, 2024
    Configuration menu
    Copy the full SHA
    7e81de0 View commit details
    Browse the repository at this point in the history
  2. [red-knot] feat: resolve literals (bool, int, str) in f-string expres…

    …sions
    
    Resolves f-strings made entirely of literals (bool, int, str) at compile
    time (not supported by mypy).
    
    Example: 'f"{True}"' -> 'True'
    Slyces committed Sep 26, 2024
    Configuration menu
    Copy the full SHA
    95b906c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    47d3544 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    eaac2cd View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    e714f9a View commit details
    Browse the repository at this point in the history
  6. [red-knot] feat: implement and use repr/str for f-strings

    Implement the methods `Type::str` and `Type::repr` for some basic types
    and use it when infering the type of an f-string expression.
    
    Ensure we always infer sub-expressions in an f-string expression, even
    when we're done figuring out its type.
    Slyces committed Sep 26, 2024
    Configuration menu
    Copy the full SHA
    9bc5a57 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    1746775 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    397aea4 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    daacaf7 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    04ed1b5 View commit details
    Browse the repository at this point in the history

Commits on Sep 27, 2024

  1. Configuration menu
    Copy the full SHA
    36a2fa4 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    47a4b3d View commit details
    Browse the repository at this point in the history