Skip to content

'None' used before definition #5938

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
miyoyo opened this issue Nov 22, 2018 · 2 comments
Closed

'None' used before definition #5938

miyoyo opened this issue Nov 22, 2018 · 2 comments

Comments

@miyoyo
Copy link

miyoyo commented Nov 22, 2018

from typing import Any, Callable, Union, List

# Singleton example taken from 
# https://python-3-patterns-idioms-test.readthedocs.io/en/latest/Singleton.html
class OperationRepository:
    class __OperationRepository:
        def __init__(self) -> None:
            zeroValue = lambda a: print()
            self.operations: List[Callable[[Any], None]] = [zeroValue]
    instance: Union[None, __OperationRepository] = None
    def __init__(self):
        if not OperationRepository.instance:
            OperationRepository.instance = OperationRepository.__OperationRepository()
    def __getattr__(self, name):
        return getattr(self.instance, name)

This above code raises this

[Python] 'None' used before definition [use-before-def] (9,30)

@JukkaL
Copy link
Collaborator

JukkaL commented Nov 22, 2018

The message is not coming from mypy -- I'm pretty sure it's generated by some other tool.

@JukkaL JukkaL closed this as completed Nov 22, 2018
@SmileyChris
Copy link

SmileyChris commented Dec 5, 2018

fyi @miyoyo you're using the MS Python Analysis Engine in VScode, and that's a known bug (#microsoft/python-language-server/issues/442) which was recently fixed, so should be in the next VScode release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants