Skip to content

Global Final variable causes type completion to fail. #702

@sudobash1

Description

@sudobash1

I am using typing.Final to type global variables in some of my modules. Here is a trivial example:

from typing import Final

test: Final = "ABC"
test. #<Cursor here

When I try to autocomplete after test. I get no results. If I remove the Final type hint then it works.

I have tried Final[str] as well, but it does not help.

This is only a global variable issue. This works:

from typing import Final

class Test:
    def __init__(self) -> None:
        self.test: Final = "ABC"

Test().test. #<Cursor here

My example here was using str for simplicity, but I have been wanting to use this pattern for a module "singleton" class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions