Skip to content

Commit 2c9522a

Browse files
committed
pylint error fix
1 parent 40f5a9b commit 2c9522a

File tree

6 files changed

+72
-4
lines changed

6 files changed

+72
-4
lines changed

examples/src/deprecated/pylintrc

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[MESSAGE CONTROL]
2+
# Disabling messages that either we don't care about we intentionally break.
3+
disable =
4+
invalid-name, # we prefer long, descriptive, names for examples
5+
bad-continuation, # we let black handle this
6+
ungrouped-imports, # we let isort handle this
7+
no-member, # breaks with attrs
8+
no-self-use, # interesting to keep in mind for later refactoring, but not blocking
9+
useless-object-inheritance, # we need to support Python 2, so no, not useless
10+
duplicate-code, # some examples may be similar
11+
too-few-public-methods, # does not allow value stores
12+
too-many-locals, # examples may sometimes have more locals defined for clarity than would be appropriate in code
13+
no-else-return, # we omit this on purpose for brevity where it would add no value
14+
attribute-defined-outside-init, # breaks with attrs_post_init
15+
abstract-method, # throws false positives on io.BaseIO grandchildren
16+
redefined-outer-name, # we do this on purpose in multiple places
17+
consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation
18+
19+
[BASIC]
20+
# Allow function names up to 50 characters
21+
function-rgx = [a-z_][a-z0-9_]{2,50}$
22+
# Allow method names up to 50 characters
23+
method-rgx = [a-z_][a-z0-9_]{2,50}$
24+
# Allow class attribute names up to 50 characters
25+
# Whitelist class attribute names: iv
26+
class-attribute-rgx = (([A-Za-z_][A-Za-z0-9_]{2,50}|(__.*__))$)|(^iv$)
27+
# Whitelist attribute names: iv
28+
attr-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)
29+
# Whitelist argument names: iv, b
30+
argument-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$)
31+
# Whitelist variable names: iv, b, _b, x, y, r, s
32+
variable-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$)|(^_b$)|(^x$)|(^y$)|(^r$)|(^s$)
33+
34+
[VARIABLES]
35+
additional-builtins = raw_input
36+
37+
[DESIGN]
38+
max-args = 10
39+
40+
[FORMAT]
41+
max-line-length = 120
42+
43+
[REPORTS]
44+
msg-template = {path}:{line}: [{msg_id}({symbol}), {obj}] {msg}

examples/src/pylintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[MESSAGE CONTROL]
22
# Disabling messages that either we don't care about we intentionally break.
33
disable =
4+
import-error, # ignore mpl import errors
45
invalid-name, # we prefer long, descriptive, names for examples
56
bad-continuation, # we let black handle this
67
ungrouped-imports, # we let isort handle this

examples/test/deprecated/pylintrc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[MESSAGES CONTROL]
2+
# Disabling messages that we either don't care about for tests or are necessary to break for tests.
3+
disable =
4+
invalid-name, # we prefer long, descriptive, names for tests
5+
missing-docstring, # we don't write docstrings for tests
6+
wrong-import-position, # similar to E0401, pylint does not appear to identify
7+
# unknown modules as non-standard-library. flake8 tests for this as well
8+
# and does treat them properly
9+
duplicate-code, # tests for similar things tend to be similar
10+
consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation
11+
12+
[VARIABLES]
13+
additional-builtins = raw_input
14+
15+
[DESIGN]
16+
max-args = 10
17+
18+
[FORMAT]
19+
max-line-length = 120
20+
21+
[REPORTS]
22+
msg-template = {path}:{line}: [{msg_id}({symbol}), {obj}] {msg}

examples/test/pylintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[MESSAGES CONTROL]
22
# Disabling messages that we either don't care about for tests or are necessary to break for tests.
33
disable =
4+
import-error, # ignore mpl import errors
45
invalid-name, # we prefer long, descriptive, names for tests
56
missing-docstring, # we don't write docstrings for tests
67
wrong-import-position, # similar to E0401, pylint does not appear to identify

examples/test/test_i_raw_rsa_keyring_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_encrypt_and_decrypt_fails_if_user_provides_only_public_key():
6060
test both encryption and decryption, or not provide any keys and the example generates both
6161
"""
6262
# Generate the user keys for testing
63-
user_public_key, user_private_key = generate_rsa_keys()
63+
user_public_key, user_private_key = generate_rsa_keys() # pylint: disable=unused-variable
6464

6565
# Convert the public key to string
6666
user_public_key = user_public_key.decode('utf-8')
@@ -92,7 +92,7 @@ def test_encrypt_and_decrypt_fails_if_user_provides_only_private_key():
9292
test both encryption and decryption, or not provide any keys and the example generates both
9393
"""
9494
# Generate the user keys for testing
95-
user_public_key, user_private_key = generate_rsa_keys()
95+
user_public_key, user_private_key = generate_rsa_keys() # pylint: disable=unused-variable
9696

9797
# Convert the private key to string
9898
user_private_key = user_private_key.decode('utf-8')

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ commands =
192192
basepython = {[testenv:pylint]basepython}
193193
deps = {[testenv:pylint]deps}
194194
commands =
195-
pylint --rcfile=examples/src/pylintrc examples/src/ --ignore-paths=examples/src/keyrings
196-
pylint --rcfile=examples/test/pylintrc --disable R0801 examples/test/ --ignore-paths=examples/test/keyrings
195+
pylint --rcfile=examples/src/pylintrc examples/src/
196+
pylint --rcfile=examples/test/pylintrc --disable R0801 examples/test/
197197

198198
[testenv:pylint-tests]
199199
basepython = {[testenv:pylint]basepython}

0 commit comments

Comments
 (0)