GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Update typing to 3.12 · Issue #5252 · RustPython/RustPython

Update typing to 3.12 #5252

New issue
Copy link
New issue
Copy link
Closed
Closed
Update typing to 3.12#5252
Copy link
Labels
C-compatA discrepancy between RustPython and CPythonA discrepancy between RustPython and CPython

Description

@dchiquito
dchiquito
opened on Apr 22, 2024
Issue body actions

Feature

The typing module needs to be updated to 3.12. It seems that it was last updated to 3.9, so it's missing several major versions worth of features, like Unpack, generics, and type aliases using the type keyword.

Not having these typing features impedes the process of updating modules that use, which presumably will be most new stuff going forward.

I estimate that updating will require:

  • Moving some abstract base classes from typing.py into a new native module typing.rs, specifically TypeVar, ParamSpec, TypeVarTuple, ParamSpecArgs, ParamSpecKwards, TypeAliasType, and Generic.
  • Adding new syntax like type type aliases and generics to the parser. It seems like this is already included in https://github.com/RustPython/Parser/blob/main/parser/src/python.lalrpop
  • Adding new instructions which generate/consume type information to compiler.rs and frame.rs. For example, def foo[T](x: T): ... must create a new TypeVar(T) and inject it into the correct scope so that it is available as an argument annotation. This requires a new instruction defined in bytecode.rs which is emitted by compiler.rs and consumed by frame.rs.
  • Copying typing.py and test_typing.py from the CPython code base.

Python Documentation or reference to CPython source code

https://docs.python.org/3/library/typing.html

Reacted by Jeong, YunWon, Toni Alatalo and Theo Paris

Activity

  1. dchiquito
    added
    C-compatA discrepancy between RustPython and CPythonA discrepancy between RustPython and CPython
    on Apr 22, 2024
  2. dchiquito commented on Apr 22, 2024

    @dchiquito
    dchiquito
    on Apr 22, 2024
    ContributorAuthor
    More actions

    I've been chewing on this for a bit, but it's pretty slow going since I'm also learning about a lot of compilation internals. As soon as I have something that is mostly compatible with the 3.12 typing.py I will submit a partial PR to get some incremental feedback.

    Reacted by Jeong, YunWon
  3. youknowone commented on Apr 22, 2024

    @youknowone
    youknowone
    on Apr 22, 2024
    Member
    More actions

    That's awesome. Please feel free to ask anything if you stuck on something.

    About typing module, if it helps, mixing Rust and Python implementation is limited but still possible. #5254 is doing it for ExceptionGroup.

  4. hydrogen602 commented on May 12, 2024

    @hydrogen602
    hydrogen602
    on May 12, 2024
    Contributor
    More actions

    I don't know if this is already known, but I just wanted to add to the 3.12 typing discussion that if not running in release mode, syntax like def foo[T](): pass causes a panic in the parser at core/src/source_code.rs:139:9

  5. dchiquito commented on May 13, 2024

    @dchiquito
    dchiquito
    on May 13, 2024
    ContributorAuthor
    More actions

    That problem should be resolved as of #5319 / RustPython/Parser#120. Thanks for reporting!

    Reacted by Jonathan Rotter and Jeong, YunWon
  6. hbina commented on Jan 31, 2025

    @hbina
    hbina
    on Jan 31, 2025
    Contributor
    More actions

    Hi, what is the progress on this? Is there a way I can help? Trying to get started with RustPython myself :)

  7. youknowone commented on Jan 31, 2025

    @youknowone
    youknowone
    on Jan 31, 2025
    Member
    More actions

    @hbina Hi, open Lib/test/test_typing.py in RustPython source code and search # TODO: RUSTPYTHON in the file. You will find many failing tests from there. Removing one of them will make cargo run -- Lib/test/test_typing.py be failed. That's the starting point.

    Please share any blocker you meet. Thanks!

  8. arihant2math commented on Mar 31, 2025

    @arihant2math
    arihant2math
    on Mar 31, 2025
    Contributor
    More actions

    #5590 should fix this.

  9. arihant2math
    closed this as completedon Apr 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-compatA discrepancy between RustPython and CPythonA discrepancy between RustPython and CPython

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.