Skip to content
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

MNT: Refactors the code to adopt pylint #621

Merged
merged 29 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4f09ee7
MNT: remove useless return None
Gui-FernandesBR Jun 14, 2024
c4bb9eb
MNT: removes more "useless return None"
Gui-FernandesBR Jun 14, 2024
4054ba1
MNT: singleton-comparison == None
Gui-FernandesBR Jun 14, 2024
6cd0a93
MNT: singleton-comparison == True and == False
Gui-FernandesBR Jun 14, 2024
8925a19
MNT: singleton-comparison != None
Gui-FernandesBR Jun 14, 2024
055f15d
MNT: small fixes for pylint
Gui-FernandesBR Jun 14, 2024
4966f19
DEV: updates pylint and isort rules
Gui-FernandesBR Jun 14, 2024
ad7e3bb
DEV: updates linters workflows
Gui-FernandesBR Jun 14, 2024
8aab5a9
MNT: more pylint fixes
Gui-FernandesBR Jun 15, 2024
fed90a8
MNT: more pylint fixes
Gui-FernandesBR Jun 15, 2024
404b17d
DEV: update pylint and flake8 rules
Gui-FernandesBR Jun 15, 2024
ae6c22a
MNT: fixes several pylint errors
Gui-FernandesBR Jun 23, 2024
da8673e
MNT: runs pylint-silent
Gui-FernandesBR Jun 23, 2024
b3036cb
Merge branch 'develop' into mnt/update-pylint-rules
Gui-FernandesBR Jun 23, 2024
3af0f11
TST Refactor test_environment.py to use np.isclose without explicit c…
Gui-FernandesBR Jun 23, 2024
75428d6
Merge branch 'develop' into mnt/update-pylint-rules
Gui-FernandesBR Jun 25, 2024
6eb4fdc
DEV: Update isort configuration to include additional directories
Gui-FernandesBR Jun 25, 2024
0ce4215
Merge branch 'develop' into mnt/update-pylint-rules
Gui-FernandesBR Jun 29, 2024
d2c3691
Fix some more pylint errors
Gui-FernandesBR Jun 29, 2024
f9c9ec2
Adjust pylint rules and add more pylint silent comments
Gui-FernandesBR Jun 29, 2024
fe6c212
DEV: Update linters.yml to install additional dependencies for tests
Gui-FernandesBR Jun 29, 2024
cd50635
TST: refactors problematic `test_create_dispersion` test
Gui-FernandesBR Jun 29, 2024
e8b4869
DEV: Skip legacy tests in test_utilities.py
Gui-FernandesBR Jun 29, 2024
3c985a0
DEV: install imageio before running CI
Gui-FernandesBR Jun 29, 2024
a212854
Merge branch 'develop' into mnt/update-pylint-rules
Gui-FernandesBR Jun 29, 2024
5ed072c
Merge branch 'develop' into mnt/update-pylint-rules
Gui-FernandesBR Jun 29, 2024
45be434
Merge branch 'develop' into mnt/update-pylint-rules
Gui-FernandesBR Jul 4, 2024
2dae970
MNT: fixes pylint code after Stano's review
Gui-FernandesBR Jul 4, 2024
6908414
MNT: pylint some of the tests
Gui-FernandesBR Jul 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions .github/workflows/lint_black.yaml

This file was deleted.

41 changes: 41 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Linters

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- "**.py"
- "**.ipynb"
- ".github/**"
- "pyproject.toml"
- "requirements*"
- ".pylintrc"

jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[all]
pip install .[tests]
pip install pylint isort
- name: Run isort
run: isort --check-only rocketpy/ tests/ docs/ --profile black
- name: Run black
uses: psf/black@stable
with:
options: "--check rocketpy/ tests/ docs/"
jupyter: true
- name: Run pylint
run: |
pylint rocketpy/
4 changes: 3 additions & 1 deletion .github/workflows/test_pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ jobs:
run: python -c "import sys, rocketpy; print(f'{rocketpy.__name__} running on Python {sys.version}')"

- name: Install test dependencies
run: pip install -r requirements-tests.txt
run: |
pip install -r requirements-tests.txt
pip install .[all]

- name: Run Unit Tests
run: pytest tests/unit --cov=rocketpy
Expand Down
58 changes: 46 additions & 12 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fail-under=10
#from-stdin=

# Files or directories to be skipped. They should be base names, not paths.
ignore=CVS, docs
ignore=CVS, docs, data,

# Add files or directories matching the regular expressions patterns to the
# ignore-list. The regex matches against paths and can be in Posix or Windows
Expand Down Expand Up @@ -212,7 +212,21 @@ good-names=FlightPhases,
fin_set_NACA,
fin_set_E473,
HIRESW_dictionary,

prop_I_11,
Kt, # transformation matrix transposed
clalpha2D,
clalpha2D_incompresible,
r_NOZ, # Nozzle position vector
rocket_dry_I_33,
rocket_dry_I_11,
motor_I_33_at_t,
motor_I_11_at_t,
motor_I_33_derivative_at_t,
motor_I_11_derivative_at_t,
M3_forcing,
M3_damping,
CM_to_CDM,
CM_to_CPM,
Gui-FernandesBR marked this conversation as resolved.
Show resolved Hide resolved

# Good variable names regexes, separated by a comma. If names match any regex,
# they will always be accepted
Expand All @@ -222,6 +236,8 @@ good-names-rgxs= ^[a-z][0-9]?$, # Single lowercase characters, possibly followe
^(dry_|propellant_)[A-Z]+_\d+$, # Variables starting with 'dry_' or 'propellant_', followed by uppercase characters, underscore, and digits
^[a-z]+_ISA$, # Lowercase words ending with '_ISA'
^plot(1D|2D)$, # Variables starting with 'plot' followed by '1D' or '2D'
S_noz*, # nozzle gyration tensor
r_CM*, # center of mass position and its variations

# Include a hint for the correct naming format with invalid-name.
include-naming-hint=no
Expand Down Expand Up @@ -312,16 +328,16 @@ exclude-too-few-public-methods=
ignored-parents=

# Maximum number of arguments for function / method.
max-args=10
max-args=15

# Maximum number of attributes for a class (see R0902).
max-attributes=30
max-attributes=50

# Maximum number of boolean expressions in an if statement (see R0916).
max-bool-expr=5

# Maximum number of branch for function / method body.
max-branches=12
max-branches=25

# Maximum number of locals for function / method body.
max-locals=30
Expand All @@ -330,16 +346,16 @@ max-locals=30
max-parents=7

# Maximum number of public methods for a class (see R0904).
max-public-methods=40
max-public-methods=25

# Maximum number of return / yield for function / method body.
max-returns=6
max-returns=25

# Maximum number of statements in function / method body.
max-statements=50
max-statements=25

# Minimum number of public methods for a class (see R0903).
min-public-methods=2
min-public-methods=0


[EXCEPTIONS]
Expand Down Expand Up @@ -454,14 +470,32 @@ disable=raw-checker-failed,
file-ignored,
suppressed-message,
useless-suppression,
deprecated-pragma,
deprecated-pragma, # because we have some peniding deprecations in the code.
use-symbolic-message-instead,
use-implicit-booleaness-not-comparison-to-string,
use-implicit-booleaness-not-comparison-to-zero,
no-else-return,
no-else-return, # this is a style preference, we don't need to follow it
inconsistent-return-statements,
unspecified-encoding,
unspecified-encoding, # this is not a relevant issue.
no-member, # because we use funcify_method decorator
invalid-overridden-method, # because we use funcify_method decorator
too-many-function-args, # because we use funcify_method decorator
fixme, # because we use TODO in the code
missing-module-docstring, # not useful for most of the modules.
attribute-defined-outside-init, # to avoid more than 200 errors (code works fine)
Gui-FernandesBR marked this conversation as resolved.
Show resolved Hide resolved
not-an-iterable, # rocketpy Functions are iterable, false positive
too-many-function-args, # gives false positives for Function calls
method-hidden, # avoids some errors in tank_geometry and flight classes
missing-timeout, # not a problem to use requests without timeout
protected-access, # we use private attriubutes out of the class (maybe we should fix this)
duplicate-code, # repeating code is a bad thing, but should we really care about it?
line-too-long, # black already takes care of this
missing-function-docstring, # this is too verbose.
redefined-outer-name, # too verbose, and doesn't add much value
method-cache-max-size-none,
no-else-raise, # pointless



# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ black:
black rocketpy/ tests/ docs/

pylint:
-pylint rocketpy tests --output=.pylint-report.txt
-pylint rocketpy --output=.pylint-report.txt

build-docs:
cd docs && $(PYTHON) -m pip install -r requirements.txt && make html
Expand Down
11 changes: 10 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ line-length = 88
include = '\.py$|\.ipynb$'
skip-string-normalization = true

[tool.isort]
profile = "black"

[tool.coverage.report]
# Regexes for lines to exclude from consideration
exclude_also = [
Expand All @@ -71,7 +74,13 @@ exclude_also = [
[tool.flake8]
max-line-length = 88
max-module-lines = 3000
ignore = ['E203', 'W503']
ignore = [
'W503', # conflicts with black
'E203', # conflicts with black
'E501', # line too long, already checked by black and pylint
'E266', # too many leading '#' for block comment, this is pointless
'F401', # imported but unused, already checked by pylint
]
exclude = [
'.git,__pycache__',
]
Loading
Loading