Skip to content

Instantly share code, notes, and snippets.

@pcorpet
Last active January 11, 2017 23:42
Show Gist options
  • Select an option

  • Save pcorpet/a0eaa282754a95273bccacd07419d1f7 to your computer and use it in GitHub Desktop.

Select an option

Save pcorpet/a0eaa282754a95273bccacd07419d1f7 to your computer and use it in GitHub Desktop.
Minimal code to reproduce PyLint bug around infered, ignored, no-member
"""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