Last active
January 11, 2017 23:42
-
-
Save pcorpet/a0eaa282754a95273bccacd07419d1f7 to your computer and use it in GitHub Desktop.
Minimal code to reproduce PyLint bug around infered, ignored, no-member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Minimal code to reproduce PyLint bug around infered, ignored, no-member.""" | |
| import os | |
| class MyVeryOwnError(ValueError): | |
| """My Exception class.""" | |
| node = True | |
| def main(): | |
| """Have main code in here so that PyLint does not pick on global vars.""" | |
| # Use the environment to create a var (owner) that can be one of two types. | |
| if os.getenv('CAT') == 'dead': | |
| owner = ValueError('dead') | |
| else: | |
| owner = MyVeryOwnError('alive') | |
| # In here owner can only be of type MyVeryOwnError. | |
| print(owner.node) | |
| if os.getenv('CAT') != 'dead': | |
| # In here although owner can only be of type MyVeryOwnError, PyLint won't | |
| # detect it and will infer it to be either a ValueError or a | |
| # MyVeryOwnError instance. | |
| print(owner.node) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment