Skip to content
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

NotSet is unknown import symbol #2192

Open
ocket8888 opened this issue Mar 2, 2022 · 1 comment · May be fixed by #2193
Open

NotSet is unknown import symbol #2192

ocket8888 opened this issue Mar 2, 2022 · 1 comment · May be fixed by #2193
Labels

Comments

@ocket8888
Copy link

ocket8888 commented Mar 2, 2022

Checking this code:

from github.GithubObject import NotSet

with Pyright version 1.1.225 fails with the error "NotSet" is unknown import symbol.

The definition of NotSet from GithubObject.py is

class _NotSetType:
    def __repr__(self):
        return "NotSet"

    value = None


NotSet = _NotSetType()

A typing that would fix this unknown import problem is

from typing import Final

class _NotSetType:
    def __repr__(self):
        return "NotSet"

    value = None


NotSet:  Final = _NotSetType()

However, that doesn't allow me to use NotSet as a type, like:

from typing import Union
from github.GithubObject import NotSet

def print_something(a: Union[str, NotSet]) -> None:
    if a is NotSet:
        print(a.value)
    else:
        print(a)

Which fails with the error Expected class type but received "_NotSetType".

@stale
Copy link

stale bot commented May 1, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant