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.

access_member_before_definition.py 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # pylint: disable=missing-docstring,too-few-public-methods,invalid-name
  2. # pylint: disable=attribute-defined-outside-init
  3. class Aaaa(object):
  4. """class with attributes defined in wrong order"""
  5. def __init__(self):
  6. var1 = self._var2 # [access-member-before-definition]
  7. self._var2 = 3
  8. self._var3 = var1
  9. class Bbbb(object):
  10. A = 23
  11. B = A
  12. def __getattr__(self, attr):
  13. try:
  14. return self.__repo
  15. except AttributeError:
  16. self.__repo = attr
  17. return attr
  18. def catchme(self, attr):
  19. """no AttributeError catched"""
  20. try:
  21. return self._repo # [access-member-before-definition]
  22. except ValueError:
  23. self._repo = attr
  24. return attr
  25. class Mixin(object):
  26. def test_mixin(self):
  27. """Don't emit access-member-before-definition for mixin classes."""
  28. if self.already_defined:
  29. # pylint: disable=attribute-defined-outside-init
  30. self.already_defined = None