diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2022-03-24 15:48:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-24 15:48:21 +0100 |
commit | 6bbb56539f27347fc8f69733e0ebbccd2318f287 (patch) | |
tree | 54c45264e47efbcbf53aee6b8851ef244c180613 | |
parent | 40d9eae15e6727b9b6dca82da2b984b4223cc4a3 (diff) | |
download | pylint-git-6bbb56539f27347fc8f69733e0ebbccd2318f287.tar.gz |
Add documentation for access-member-before-definition (#5958)
Co-authored-by: Vladyslav Krylasov <vladyslav.krylasov@gmail.com>
-rw-r--r-- | doc/data/messages/a/access-member-before-definition/bad.py | 5 | ||||
-rw-r--r-- | doc/data/messages/a/access-member-before-definition/good.py | 5 | ||||
-rw-r--r-- | pylint/checkers/classes/class_checker.py | 6 |
3 files changed, 15 insertions, 1 deletions
diff --git a/doc/data/messages/a/access-member-before-definition/bad.py b/doc/data/messages/a/access-member-before-definition/bad.py new file mode 100644 index 000000000..cb17c86ee --- /dev/null +++ b/doc/data/messages/a/access-member-before-definition/bad.py @@ -0,0 +1,5 @@ +class Foo: + def __init__(self, param): + if self.param: # [access-member-before-definition] + pass + self.param = param diff --git a/doc/data/messages/a/access-member-before-definition/good.py b/doc/data/messages/a/access-member-before-definition/good.py new file mode 100644 index 000000000..b2c877a4b --- /dev/null +++ b/doc/data/messages/a/access-member-before-definition/good.py @@ -0,0 +1,5 @@ +class Foo: + def __init__(self, param): + self.param = param + if self.param: + pass diff --git a/pylint/checkers/classes/class_checker.py b/pylint/checkers/classes/class_checker.py index 91343a5d2..7492c9b42 100644 --- a/pylint/checkers/classes/class_checker.py +++ b/pylint/checkers/classes/class_checker.py @@ -830,7 +830,11 @@ a metaclass class method.", node=node, ) - @check_messages("unused-private-member", "attribute-defined-outside-init") + @check_messages( + "unused-private-member", + "attribute-defined-outside-init", + "access-member-before-definition", + ) def leave_classdef(self, node: nodes.ClassDef) -> None: """Checker for Class nodes. |