Skip to content

stubgen: mangles from _typeshed import Incomplete on Windows #16658

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

Closed
Josverl opened this issue Dec 12, 2023 · 12 comments
Closed

stubgen: mangles from _typeshed import Incomplete on Windows #16658

Josverl opened this issue Dec 12, 2023 · 12 comments
Labels
bug mypy got something wrong topic-stubgen

Comments

@Josverl
Copy link

Josverl commented Dec 12, 2023

Bug Report
When stubgen creates stubs for a module that imports Incomplete , it then mangles / overcomplicates the import in the generated stub
edit : On Windows

To Reproduce - minimal repro

from _typeshed import Incomplete


def polar(*args, **kwargs) -> Incomplete:
    ...

running stubgen results in

from _typeshed import Incomplete as Incomplete

def polar(*args, **kwargs) -> Incomplete: ...

Environment

  • Mypy version used: 1.7.0
  • Mypy command-line flags: - none
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.11
  • OS: Windows_NT x64 10.0.26100
@Josverl Josverl added the bug mypy got something wrong label Dec 12, 2023
@Josverl Josverl changed the title stubgen: mangles stubgen: mangles from _typeshed import Incomplete Dec 12, 2023
@makridenko
Copy link
Contributor

@Josverl hi! I think it's outdated issue

@Josverl
Copy link
Author

Josverl commented May 22, 2025

I can prove it still reproduces with stubgen 1.15.0.

@makridenko Why do you think it is outdated ?

@makridenko
Copy link
Contributor

@Josverl I've tried to reproduce it with master-branch stubgen and it works fine. I guess we need to wait for release

@Josverl
Copy link
Author

Josverl commented May 22, 2025

Perhaps to be clearer
The bug is the 2x Incomplete in Incomplete as Incomplete

Expected

from _typeshed import Incomplete

def polar(*args, **kwargs) -> Incomplete

So the bug is still not resolved.

@makridenko
Copy link
Contributor

In master branch everything is working as expected:

Image

@sobolevn
Copy link
Member

sobolevn commented Jun 8, 2025

Do we have a test case for that?

@makridenko
Copy link
Contributor

@sobolevn I can add the test that's in the screenshot above

@makridenko
Copy link
Contributor

@sobolevn #19253

@Josverl
Copy link
Author

Josverl commented Jun 8, 2025

Ill verify the current state as I can't explain why the behavior is different for @makridenko than for me.
Also the previous reported behavior by @makridenko was same as mine, so something changed....

That might also mean that the test case is not covering the all relevant aspects.

Ill report back here.

@Josverl
Copy link
Author

Josverl commented Jun 9, 2025

@sobolevn Im sorry , but i need to report that the issue indeed is not fixed.
The same issue still occurs, but appears to be specific to stubgen running on Windows.
I did not include that in my initial report, as I assumed that that would not matter.

Is stubgen tested on anything but Ubuntu ? ( there are a lot of tests skipped on Windows)

See : https://github.com/Josverl/mypy_mangle

@Josverl Josverl changed the title stubgen: mangles from _typeshed import Incomplete stubgen: mangles from _typeshed import Incomplete on Windows Jun 9, 2025
@makridenko
Copy link
Contributor

@Josverl thank you for clarifying this, unfortunately I don't have any windows machine.
@sobolevn could you test this?

@Josverl
Copy link
Author

Josverl commented Jun 10, 2025

a few points.

  1. The tests that was added is part of a suite that is skipped on Windows. ( along with the rest of the suite)
    ```
    pytest mypy\test\teststubgen.py::StubgenPythonSuite::stubgen.test::testIncompleteReturn
    ========================================================================= test session starts ==========================================================================
    platform win32 -- Python 3.11.9, pytest-8.3.5, pluggy-1.5.0
    rootdir: D:\mypython!-stubtestprojects\mypy_mangle\mypy
    configfile: pyproject.toml
    plugins: anyio-4.6.0, time-machine-2.16.0
    collected 1 item

     mypy\test\teststubgen.py s                                                                                                                                        [100%] 
     
     ========================================================================== 1 skipped in 0.44s ==========================================================================
     ```
    
  2. When I remove that skipif guard , the tests passes, but the stubgen behaviour is still incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-stubgen
Projects
None yet
Development

No branches or pull requests

4 participants