Skip to content

Lint Python code #270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DifferentialOrange opened this issue Dec 7, 2022 · 0 comments · Fixed by #289
Closed

Lint Python code #270

DifferentialOrange opened this issue Dec 7, 2022 · 0 comments · Fixed by #289
Assignees
Labels
code health Improve code readability, simplify maintenance and so on feature A new functionality

Comments

@DifferentialOrange
Copy link
Member

Add some linter (pylint, flake8) to CI runs.

The task itself is rather simple, yet before merging this we should resolve any conflicts. And pylint yielded a couple of hundreds of them (not counting missing docstring ones).

@DifferentialOrange DifferentialOrange added feature A new functionality code health Improve code readability, simplify maintenance and so on teamE labels Dec 7, 2022
@DifferentialOrange DifferentialOrange self-assigned this Mar 27, 2023
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Last PEP8 checkup was in 0.5.5 [1]. Many things has changed since in
both PEP8 and connector source code. To ensure that everything is
alright, this patch removes existing pylint ignores before pylint
checkup. They could be restored after thorough checkup.

1. 93b5d3d

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Fix all cases of C0303 trailing-whitespace. Remove trailing whitespaces
from documentation as well.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Fix several cases of C0103 invalid-name.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
`t` sounds like a reasonable variable names in tests, `ok` sounds like a
reasonable variable names in general. This patch disables C0103
invalid-name check for them.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
`tz` is a part of the Datetime public API and we don't plan to change it
now.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
unittest methods use CamelCase for its asserts. We use it here for our
custom assert too.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Lowercase constants are the part of dbapi, we cannot rename them.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Lowercase constants are the part of sphinx API, we cannot rename them.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Fix all cases of C0121 singleton-comparison.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Fix all cases of C0209 consider-using-f-string.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Fix all cases of C0206 consider-using-dict-items.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Fix all cases of C0200 consider-using-enumerate.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Fix all cases of C0201 consider-iterating-dictionary.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Fix all cases of C0202 bad-classmethod-argument.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Fix all cases of C0325 superfluous-parens.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Fix all cases of C0321 multiple-statements.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Fix all cases of C0305 trailing-newlines.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Disable all current cases of C0302 too-many-lines.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Fix all cases of C0411 wrong-import-order.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Fix all cases of C0413 wrong-import-position.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Fix the only case of C0415 import-outside-toplevel.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Disable a case of C0415 import-outside-toplevel: we allow to run
commands like `python setup.py test` without setuptools_scm.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Fix all cases of C0114 missing-module-docstring.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Fix all cases of W1514 unspecified-encoding.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
distutils is starting to get removed from the standard library since
2020 and has been phased out since 2014 (or earlier). Distutils has
been exposed only recently, so relatively old Python (like 3.8)
setuptools doesn't have them yet.

1. https://peps.python.org/pep-0632
2. pypa/setuptools@974dbb0

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Fix all cases of C3001 unnecessary-lambda-assignment.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Fix the only case of E1101 no-member.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Fix the only case of C2801 unnecessary-dunder-call.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Disable cases of E1121 too-many-function-args in tests.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Fix several cases of C0301 line-too-long.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Disable remaining cases of C0301 line-too-long. Reason: they are related
to code insertion in docstrings and documentation macros.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Disable all cases of R0801 duplicate-code in code. ConnectionPool,
MeshConnection, Connection and Tarantool server have similar API, thus
they have similar init arguments.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Disable all cases of R0801 duplicate-code in tests. it may be for the
best to remove instance setup to some common place, but for now it
doesn't seems like it's worth the effort.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Disable all cases of R0201 no-self-use in code. We don't plan to change
API yet.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Allow lint to not fail for all version from Python 3.6 latest one to
python 3.10 latest one. See also [1].

1. pylint-dev/pylint#3312

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Ignore E501 line too long since it's already checked with pylint. It
seems impossible to transfer its rules like "skip docstring links and
tables by regexp", so we just skip it here.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Ignore all cases of E265 block comment should start with '# ' in
documentation configuration template.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
W503 is an outdated warning which contradicts modern W504 [1].

1. https://www.flake8rules.com/rules/W503.html

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Fix several cases of F841 local variable is assigned to but never used.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
This patch includes fixes for all remaining cases of
- E101 indentation contains mixed spaces and tabs,
- E121 continuation line under-indented for hanging
indent,
- E122 continuation line missing indentation or
outdented,
- E123 closing bracket does not match indentation of
opening bracket's line,
- E124 closing bracket does not match visual
indentation,
- E126 continuation line over-indented for hanging
indent,
- E127 continuation line over-indented for visual indent,
- E128 continuation line under-indented for visual indent,
- E131 continuation line unaligned for hanging indent,
- E201 whitespace after '(',
- E202 whitespace before '(',
- E203 Whitespace before ':',
- E221 multiple spaces before operator,
- E225 missing whitespace around operator,
- E226 missing whitespace around arithmetic operator,
- E227 missing whitespace around bitwise or shift,
operator,
- E231 missing whitespace after ',', ';', or ':',
- E241 multiple spaces after ',',
- E251 unexpected spaces around keyword / parameter
equals,
- E252 missing whitespace around parameter equals,
- E261 at least two spaces before inline comment,
- E275 missing whitespace after keyword,
- E301 expected 1 blank line,
- E302 expected 2 blank lines,
- E303 too many blank lines,
- E305 expected 2 blank lines after class or function definition,
- E306 expected 1 blank line before a nested definition,
- E502 the backslash is redundant between brackets,
- W191 indentation contains tabs,
- W293 blank line contains whitespace,
- W504 line break after binary operator.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
tarantool.error values import are the part of the DBAPI requirements, so
they cannot be omitted. The same rule is used in pylint.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Fir all remaining cases of F401 unused import.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Skip autogenerated timezones since there are too many abbreviations that
confuse codespell.

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
See [1] about global bad-option-value fail to work.

1. pylint-dev/pylint#3312

Part of #270
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
DifferentialOrange added a commit that referenced this issue Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code health Improve code readability, simplify maintenance and so on feature A new functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant