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

Enum member, instead of the value of enum member, is given the type of the actual class #2263

Closed
chazeon opened this issue Jul 7, 2018 · 4 comments
Labels
Milestone

Comments

@chazeon
Copy link

chazeon commented Jul 7, 2018

Steps to reproduce

The result is from VSCode's pylint, writing a singleton with the assistance of Enum, is the recommended way of writing singleton pattern by PEP 484:

class TestClass:
    def hello(self):
        return "Hello!"

class TestClassSingleton(enum.Enum):
    test_object = TestClass()

def get_test_object():
    return TestClassSingleton.test_object.value

test_class_instance = get_test_object()

print(test_class_instance.hello())

This code correctly prints Hello!.

Current behavior

  • The test_class_instance is of type “method 'value'”, and any call to it would result in E1101.
  • TestClassSingleton.test_object is of type TestClass

image

image

Expected behavior

  • The TestClassSingleton.test_object should be of class TestClassSingleton.
  • The test_class_instance should be of type TestClass.

pylint --version output

tpylint 1.9.2,
astroid 1.6.5
Python 3.6.1 |Anaconda custom (64-bit)| (default, May 11 2017, 13:25:24) [MSC v.1900 64 bit (AMD64)]
@PCManticore
Copy link
Contributor

I don't quite get what this issue is about. Where do you get these errors from, from pylint? If I run pylint at command line using the example you provided I get no errors. Can you paste a screenshot with the exact output you're getting from VSCode?

@PCManticore PCManticore added the Needs reproduction 🔍 Need a way to reproduce it locally on a maintainer's machine label Jul 8, 2018
@chazeon
Copy link
Author

chazeon commented Jul 8, 2018

Hi @PCManticore, I've updated it with screenshots and updated the code and description a little bit.

@PCManticore PCManticore added Bug 🪲 and removed Needs reproduction 🔍 Need a way to reproduce it locally on a maintainer's machine labels Jul 8, 2018
@PCManticore
Copy link
Contributor

Thanks, now it makes more sense!

@Pierre-Sassoulas
Copy link
Member

Closing because it cannot be reproduced in the latest pylint.

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

No branches or pull requests

3 participants