Thanks to visit codestin.com
Credit goes to github.com

Skip to content

stubgen incorrectly represents function arguments whose default is None as having no default #18757

Description

@multimeric

To Reproduce

I've create a repo that reproduces this issue. It uses this simple code:

class Cls:
    def __init__(self, a = 1, b = None):
        self.a = a
        self.b = b

Note how b has a default value, but that value is None. This is different from an argument that has no default.

To reproduce:

git clone https://github.com/multimeric/StubgenBug
cd StubgenBug/
uv run stubgen --inspect-mode -m tmp_dmnkkm8uuq
cat out/tmp_dmnkkm8uuq/__init__.pyi

Expected Behavior
I would expect b to indicate the default value exists:

class Cls:
    def __init__(self, a: int = ..., b = ...) -> None: ...

Actual Behavior
b doesn't have a default:

class Cls:
    def __init__(self, a: int = ..., b) -> None: ...

Your Environment

Python 3.12.6
stubgen 1.15.0

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions