Skip to content

Regression in 1.1.390: Implicit imports conflict with explicit definitions in stub files #9992

@srittau

Description

@srittau

Describe the bug

This regression was noticed in python/typeshed#13198 and prevents us from upgrading pyright past 1.1.389:

Currently, the stubs for icalendar/__init__.pyi contains the following definition:

from .version import version as version

where version is defined in icalendar/version.pyi as:

version: Final[str]

This fails since trying to update to 1.1.390:

/home/runner/work/typeshed/typeshed/stubs/icalendar/icalendar/__init__.pyi
  /home/runner/work/typeshed/typeshed/stubs/icalendar/icalendar/__init__.pyi:48:7 - error: "version" is declared as Final and cannot be reassigned 

See this CI run, for example, which is using pyright 1.1.395: https://github.com/python/typeshed/actions/runs/13564502381/job/37914468832?pr=13198

I suspect the problem here is that version is first imported implicitly as a module (from .version), which is then overridden by the import version part (or vice versa). While this is an accurate representation of what happens at runtime, the conflict here is less than helpful. The implicit import is a rather arcane – and certainly not recommended to use – feature, and in this particular instance, the version module name is quickly overridden.

I'd rather wish pyright would not support implicitly imports like this.

VS Code extension or command-line

It's run in typeshed's CI using the GitHub action jakebailey/pyright-action@v2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    as designedNot a bug, working as intendedbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions