◐ Shell
reader mode source ↗
Skip to content

typing upgrade to 3.13.2#5590

Merged
youknowone merged 23 commits into
RustPython:mainfrom
arihant2math:typing-unpack
Apr 27, 2025
Merged

typing upgrade to 3.13.2#5590
youknowone merged 23 commits into
RustPython:mainfrom
arihant2math:typing-unpack

Conversation

@arihant2math

@arihant2math arihant2math commented Mar 9, 2025

Copy link
Copy Markdown
Contributor

Fixes: #5584 #5252
Closes: #4946

@moreal moreal mentioned this pull request Mar 10, 2025
@arihant2math arihant2math marked this pull request as draft March 24, 2025 04:58
@youknowone

Copy link
Copy Markdown
Member

The failing tests are unexpected success. Removing expectedFailure will fix them

@arihant2math

Copy link
Copy Markdown
Contributor Author

Rebasing has lead to an import error/compiler panic.

@youknowone

Copy link
Copy Markdown
Member

That's because _py_exception_group.py is recently merged.
It uses those features form typing:

from typing import TYPE_CHECKING, Generic, Type, TypeVar, cast, overload

Any chance to break one of them?

@arihant2math

Copy link
Copy Markdown
Contributor Author

hmmm. Blocking on #5622, so I can rewrite that in rust.

@arihant2math

Copy link
Copy Markdown
Contributor Author

Oh wait I can just break that import statement :D

@arihant2math

arihant2math commented Apr 5, 2025

Copy link
Copy Markdown
Contributor Author

Blocked on #5628 so I can atleast partially fix codegen.
(I need to use unit tests to see disassembly output)

@arihant2math

Copy link
Copy Markdown
Contributor Author

One minor issue ... the pip install needs to be fixed. I can't really replicate on my machine because I'm on windows.

2 hidden items Load more…
@youknowone

Copy link
Copy Markdown
Member

resolve_mro fails

Traceback (most recent call last):
  File "<stdin>", line 6, in <module>
  File "~/Projects/RustPython/pylib/Lib/runpy.py", line 224, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "~/Projects/RustPython/pylib/Lib/runpy.py", line 94, in _run_module_code
    with _TempModule(mod_name) as temp_module, _ModifiedArgv0(fname):
  File "~/Projects/RustPython/pylib/Lib/runpy.py", line 97, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "~/Projects/RustPython/pylib/Lib/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/var/folders/4l/db5by6f97gl8z692_wckqb3w0000gn/T/tmpp0rarl2n/pip-23.2.1-py3-none-any.whl/pip/__main__.py", line 24, in <module>
  File "/var/folders/4l/db5by6f97gl8z692_wckqb3w0000gn/T/tmpp0rarl2n/pip-23.2.1-py3-none-any.whl/pip/_internal/cli/main.py", line 77, in main
  File "/var/folders/4l/db5by6f97gl8z692_wckqb3w0000gn/T/tmpp0rarl2n/pip-23.2.1-py3-none-any.whl/pip/_internal/commands/__init__.py", line 114, in create_command
  File "~/Projects/RustPython/pylib/Lib/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "_frozen_importlib", line 1382, in _gcd_import
  File "_frozen_importlib", line 1352, in _find_and_load
  File "_frozen_importlib", line 1355, in _find_and_load
  File "_frozen_importlib", line 1329, in _find_and_load_unlocked
  File "_frozen_importlib", line 1326, in _find_and_load_unlocked
  File "_frozen_importlib", line 1326, in _find_and_load_unlocked
  File "_frozen_importlib", line 945, in _load_unlocked
  File "_frozen_importlib", line 943, in _load_unlocked
  File "_frozen_importlib", line 936, in _load_unlocked
  File "_frozen_importlib", line 930, in _load_unlocked
  File "_frozen_importlib_external", line 994, in exec_module
  File "_frozen_importlib", line 488, in _call_with_frames_removed
  File "/var/folders/4l/db5by6f97gl8z692_wckqb3w0000gn/T/tmpp0rarl2n/pip-23.2.1-py3-none-any.whl/pip/_internal/commands/install.py", line 15, in <module>
  File "/var/folders/4l/db5by6f97gl8z692_wckqb3w0000gn/T/tmpp0rarl2n/pip-23.2.1-py3-none-any.whl/pip/_internal/cli/req_command.py", line 26, in <module>
  File "/var/folders/4l/db5by6f97gl8z692_wckqb3w0000gn/T/tmpp0rarl2n/pip-23.2.1-py3-none-any.whl/pip/_internal/operations/prepare.py", line 32, in <module>
  File "/var/folders/4l/db5by6f97gl8z692_wckqb3w0000gn/T/tmpp0rarl2n/pip-23.2.1-py3-none-any.whl/pip/_internal/network/download.py", line 11, in <module>
  File "/var/folders/4l/db5by6f97gl8z692_wckqb3w0000gn/T/tmpp0rarl2n/pip-23.2.1-py3-none-any.whl/pip/_internal/cli/progress_bars.py", line 4, in <module>
  File "/var/folders/4l/db5by6f97gl8z692_wckqb3w0000gn/T/tmpp0rarl2n/pip-23.2.1-py3-none-any.whl/pip/_vendor/rich/progress.py", line 273, in <module>
  File "~/Projects/RustPython/pylib/Lib/_py_abc.py", line 36, in __new__
    cls = super().__new__(mcls, name, bases, namespace, **kwargs)
TypeError: duplicate base class Generic
Traceback (most recent call last):
  File "~/Projects/RustPython/pylib/Lib/runpy.py", line 197, in _run_module_as_main
    "__main__", mod_spec)
  File "~/Projects/RustPython/pylib/Lib/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "~/Projects/RustPython/pylib/Lib/ensurepip/__main__.py", line 5, in <module>
    sys.exit(ensurepip._main())
  File "~/Projects/RustPython/pylib/Lib/ensurepip/__init__.py", line 290, in _main
    default_pip=args.default_pip,
  File "~/Projects/RustPython/pylib/Lib/ensurepip/__init__.py", line 167, in _bootstrap
    with tempfile.TemporaryDirectory() as tmpdir:
  File "~/Projects/RustPython/pylib/Lib/ensurepip/__init__.py", line 200, in _bootstrap
    return _run_pip([*args, *_PACKAGE_NAMES], additional_paths)
  File "~/Projects/RustPython/pylib/Lib/ensurepip/__init__.py", line 101, in _run_pip
    return subprocess.run(cmd, check=True).returncode
  File "~/Projects/RustPython/pylib/Lib/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
  File "~/Projects/RustPython/pylib/Lib/subprocess.py", line 572, in run
    output=stdout, stderr=stderr)
CalledProcessError: (1, ['~/Projects/RustPython/target/debug/rustpython', '-W', 'ignore::DeprecationWarning', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/var/folders/4l/db5by6f97gl8z692_wckqb3w0000gn/T/tmpp0rarl2n/pip-23.2.1-py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/var/folders/4l/db5by6f97gl8z692_wckqb3w0000gn/T/tmpp0rarl2n\', \'--upgrade\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n'])

@youknowone youknowone closed this Apr 22, 2025
@youknowone youknowone reopened this Apr 22, 2025
@youknowone

youknowone commented Apr 22, 2025

Copy link
Copy Markdown
Member

While creating a class _ReadContext, it takes 3 bases but 2 of them are Generic:

new heap type: _ReadContext
-- start resolve_mro for:AbstractContextManager, Generic, Generic, 
   base: AbstractContextManager
   base: Generic
   base: Generic

The class is this one: https://github.com/pypa/pip/blob/24f4600851bbb3d7f22aed0ba6b1e2dcc4973412/src/pip/_vendor/rich/progress.py#L287-L305

@youknowone

youknowone commented Apr 22, 2025

Copy link
Copy Markdown
Member

Reproducible code

import typing
from typing import ContextManager, Generic, TextIO, BinaryIO
_I = typing.TypeVar("_I", TextIO, BinaryIO)
class _ReadContext(ContextManager[_I], Generic[_I]):
    pass

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
@arihant2math

Copy link
Copy Markdown
Contributor Author

Great, that's fixed.

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
@arihant2math

Copy link
Copy Markdown
Contributor Author

Finally, it all works.
Ready for review.

@arihant2math

Copy link
Copy Markdown
Contributor Author

@youknowone do you mind reviewing please?

@youknowone

Copy link
Copy Markdown
Member

Even though there are regressions, merging this have benefits to fix pip

@youknowone youknowone merged commit d46bcd9 into RustPython:main Apr 27, 2025
@arihant2math arihant2math deleted the typing-unpack branch April 27, 2025 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError when using pip==25.0.1

2 participants