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.

func_noerror_access_attr_before_def_false_positive.py 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #pylint: disable=C0103,R0904,R0903,W0201,old-style-class,no-absolute-import
  2. """
  3. This module demonstrates a possible problem of pyLint with calling __init__ s
  4. from inherited classes.
  5. Initializations done there are not considered, which results in Error E0203 for
  6. self.cookedq.
  7. """
  8. from __future__ import print_function
  9. import telnetlib
  10. class SeeTelnet(telnetlib.Telnet):
  11. """
  12. Extension of telnetlib.
  13. """
  14. def __init__(self, host=None, port=0):
  15. """
  16. Constructor.
  17. When called without arguments, create an unconnected instance.
  18. With a hostname argument, it connects the instance; a port
  19. number is optional.
  20. Parameter:
  21. - host: IP address of the host
  22. - port: Port number
  23. """
  24. telnetlib.Telnet.__init__(self, host, port)
  25. def readUntilArray(self, matches, _=None):
  26. """
  27. Read until a given string is encountered or until timeout.
  28. ...
  29. """
  30. self.process_rawq()
  31. maxLength = 0
  32. for match in matches:
  33. if len(match) > maxLength:
  34. maxLength = len(match)
  35. class Base(object):
  36. """bla bla"""
  37. dougloup_papa = None
  38. def __init__(self):
  39. self._var = False
  40. class Derived(Base):
  41. """derived blabla"""
  42. dougloup_moi = None
  43. def Work(self):
  44. """do something"""
  45. # E0203 - Access to member '_var' before its definition
  46. if self._var:
  47. print("True")
  48. else:
  49. print("False")
  50. self._var = True
  51. # E0203 - Access to member 'dougloup_papa' before its definition
  52. if self.dougloup_papa:
  53. print('dougloup !')
  54. self.dougloup_papa = True
  55. # E0203 - Access to member 'dougloup_moi' before its definition
  56. if self.dougloup_moi:
  57. print('dougloup !')
  58. self.dougloup_moi = True
  59. class QoSALConnection(object):
  60. """blabla"""
  61. _the_instance = None
  62. def __new__(cls):
  63. if cls._the_instance is None:
  64. cls._the_instance = object.__new__(cls)
  65. return cls._the_instance
  66. def __init__(self):
  67. pass
  68. class DefinedOutsideInit(object):
  69. """use_attr is seen as the method defining attr because its in
  70. first position
  71. """
  72. def __init__(self):
  73. self.reset()
  74. def use_attr(self):
  75. """use and set members"""
  76. if self.attr:
  77. print('hop')
  78. self.attr = 10
  79. def reset(self):
  80. """reset members"""
  81. self.attr = 4