Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

namedtuple_member_inference.py 559B

12345678910111213141516171819202122
  1. """Test namedtuple attributes.
  2. Regression test for:
  3. https://bitbucket.org/logilab/pylint/issue/93/pylint-crashes-on-namedtuple-attribute
  4. """
  5. from __future__ import absolute_import, print_function
  6. from collections import namedtuple
  7. __revision__ = None
  8. Thing = namedtuple('Thing', ())
  9. Fantastic = namedtuple('Fantastic', ['foo'])
  10. def test():
  11. """Test member access in named tuples."""
  12. print(Thing.x) # [no-member]
  13. fan = Fantastic(1)
  14. print(fan.foo)
  15. # Should not raise protected-access.
  16. fan2 = fan._replace(foo=2)
  17. print(fan2.foo)