8000 DEV: adds ruff, removes black, isort and flake8 by Gui-FernandesBR · Pull Request #763 · RocketPy-Team/RocketPy · GitHub
[go: up one dir, main page]

Skip to content

DEV: adds ruff, removes black, isort and flake8 #763

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

Merged
merged 8 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 7 additions & 10 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,11 @@ jobs:
python -m pip install --upgrade pip
pip install .[all]
pip install .[tests]
pip install pylint isort black
- 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
pip install pylint ruff
- name: Ruff (lint)
run: ruff check --output-format=github .
- name: Ruff (format)
run: ruff format --check .
- name: Pylint
run: |
pylint rocketpy/ tests/
pylint rocketpy/ tests/ docs/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ coverage.xml
.pytest_cache/
cover/
.pylint-report.txt
.ruff-report.txt

# Translations
*.mo
Expand Down
9 changes: 5 additions & 4 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, data,
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 @@ -214,7 +214,7 @@ good-names=FlightPhases,
HIRESW_dictionary,
prop_I_11,
Kt, # transformation matrix transposed
clalpha2D,
clalpha2D,
clalpha2D_incompressible,
r_NOZ, # Nozzle position vector
rocket_dry_I_33,
Expand Down Expand Up @@ -475,7 +475,7 @@ disable=raw-checker-failed,
file-ignored,
suppressed-message,
useless-suppression,
deprecated-pragma, # because we have some peniding deprecations in the code.
deprecated-pragma, # because we have some pending deprecations in the code.
use-symbolic-message-instead,
use-implicit-booleaness-not-comparison-to-string,
use-implicit-booleaness-not-comparison-to-zero,
Expand All @@ -492,13 +492,14 @@ disable=raw-checker-failed,
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)
protected-access, # we use private attributes 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
unnecessary-lambda-assignment, # ruff already checks this



Expand Down
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"bmatrix",
"boldsymbol",
"brentq",
"Bressan",
"bysource",
"Calebe",
"calisto",
Expand Down Expand Up @@ -145,6 +146,7 @@
"headlength",
"headwidth",
"hemis",
"Henrique",
"hgtprs",
"hgtsfc",
"HIRESW",
Expand Down Expand Up @@ -188,6 +190,7 @@
"LSODA",
"lvhaack",
"Mandioca",
"Marinho",
"Marte",
"Masatoshi",
"Mateus",
Expand Down Expand Up @@ -239,7 +242,9 @@
"prettytable",
"Projeto",
"prometheus",
"pycodestyle",
"pydata",
"pydocstyle",
"pylint",
"pylintrc",
"PYPI",
Expand Down Expand Up @@ -274,6 +279,7 @@
"seblm",
"seealso",
"setrail",
"setuptools",
"simplekml",
"SIRGAS",
"Sobol",
Expand Down
18 changes: 7 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,17 @@ install:
pip install -r requirements-optional.txt
pip install -e .

format: isort black
format:
ruff check --select I --fix rocketpy/ tests/ docs/
ruff format rocketpy/ tests/ docs/

isort:
isort --profile black rocketpy/ tests/ docs/
lint: ruff-lint pylint

black:
black rocketpy/ tests/ docs/

lint: flake8 pylint

flake8:
flake8 rocketpy/ tests/
ruff-lint:
ruff check rocketpy/ tests/ docs/ --output-file=.ruff-report.txt

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

build-docs:
cd docs && $(PYTHON) -m pip install -r requirements.txt && make html
Expand Down
10 changes: 5 additions & 5 deletions docs/examples/SEB_liquid_motor.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
"outputs": [],
"source": [
"from rocketpy import (\n",
" CylindricalTank,\n",
" Environment,\n",
" Flight,\n",
" Fluid,\n",
" Function,\n",
" LiquidMotor,\n",
" UllageBasedTank,\n",
" MassBasedTank,\n",
" Fluid,\n",
" Rocket,\n",
" Flight,\n",
" Environment,\n",
" CylindricalTank,\n",
" UllageBasedTank,\n",
")"
]
},
Expand Down
9 changes: 3 additions & 6 deletions docs/examples/andromeda_flight_sim.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from rocketpy import Function, Environment, Flight, Rocket, SolidMotor\n",
"from rocketpy.motors import CylindricalTank, SolidMotor\n",
"from rocketpy.motors.tank import MassFlowRateBasedTank\n",
"\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from rocketpy import Environment, Flight, Function, Rocket, SolidMotor\n",
"\n",
"plt.style.use(\"seaborn-v0_8-colorblind\")"
]
},
Expand Down Expand Up @@ -452,7 +450,6 @@
"source": [
"from rocketpy.simulation.flight_data_importer import FlightDataImporter\n",
"\n",
"\n",
"columns_map = {\n",
" \"t(s)\": \"time\",\n",
" \"alt(m)\": \"altitude\",\n",
Expand Down
21 changes: 12 additions & 9 deletions docs/examples/camoes_flight_sim.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,20 @@
},
{
"cell_type": "code",
"execution_count": 62,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from rocketpy import Function, Environment, Flight, Rocket, SolidMotor\n",
"from rocketpy import AirBrakes, _Controller\n",
"from rocketpy.motors import CylindricalTank, SolidMotor\n",
"from rocketpy.motors.tank import MassFlowRateBasedTank\n",
"\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from rocketpy import (\n",
" Environment,\n",
" Flight,\n",
" Function,\n",
" Rocket,\n",
" SolidMotor,\n",
")\n",
"\n",
"plt.style.use(\"seaborn-v0_8-colorblind\")"
]
},
Expand All @@ -65,7 +68,7 @@
},
{
"cell_type": "code",
"execution_count": 63,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -813,7 +816,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "RocketPy",
"display_name": ".venv",
"language": "python",
"name": "python3"
},
Expand All @@ -827,7 +830,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.7"
"version": "3.13.1"
}
},
"nbformat": 4,
Expand Down
8 changes: 3 additions & 5 deletions docs/examples/cavour_flight_sim.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@
"metadata": {},
"outputs": [],
"source": [
"from rocketpy import Function, Environment, Flight, Rocket, SolidMotor\n",
"from rocketpy.motors import SolidMotor\n",
"\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from rocketpy import Environment, Flight, Function, Rocket, SolidMotor\n",
"\n",
"plt.style.use(\"seaborn-v0_8-colorblind\")"
]
},
Expand Down Expand Up @@ -377,7 +376,6 @@
"source": [
"from rocketpy.simulation.flight_data_importer import FlightDataImporter\n",
"\n",
"\n",
"columns_map = {\n",
" \"ts\": \"time\",\n",
" \"altitude[m]\": \"altitude\",\n",
Expand Down Expand Up @@ -461,7 +459,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
"version": "3.13.1"
}
},
"nbformat": 4,
Expand Down
31 changes: 16 additions & 15 deletions docs/examples/defiance_flight_sim.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
"metadata": {},
"outputs": [],
"source": [
10000 "from rocketpy import Function, Environment, Rocket, Flight\n",
"import datetime\n",
"\n",
"from rocketpy import Environment, Flight, Function, Rocket\n",
"from rocketpy.motors import CylindricalTank, Fluid, HybridMotor\n",
"from rocketpy.motors.tank import MassFlowRateBasedTank\n",
"import datetime"
"from rocketpy.motors.tank import MassFlowRateBasedTank"
]
},
{
Expand Down Expand Up @@ -127,13 +128,13 @@
"metadata": {},
"outputs": [],
"source": [
"oxidizer_liq = Fluid(name='N2O_l', density=960)\n",
"oxidizer_gas = Fluid(name='N2O_g', density=1.9277)\n",
"oxidizer_liq = Fluid(name=\"N2O_l\", density=960)\n",
"oxidizer_gas = Fluid(name=\"N2O_g\", density=1.9277)\n",
"\n",
"tank_shape = CylindricalTank(0.0665, 1.79)\n",
"\n",
"oxidizer_tank = MassFlowRateBasedTank(\n",
" name='oxidizer_tank',\n",
" name=\"oxidizer_tank\",\n",
" geometry=tank_shape,\n",
" flux_time=(6.5),\n",
" liquid=oxidizer_liq,\n",
Expand All @@ -146,15 +147,15 @@
" gas_mass_flow_rate_out=0,\n",
")\n",
"\n",
"''' Defining the thrust curve'''\n",
"\"\"\" Defining the thrust curve\"\"\"\n",
"\n",
"\n",
"def thrust_fuction(t):\n",
" return 5750 * 2 ** (-t / 200)\n",
"\n",
"\n",
"hybrid_motor = HybridMotor(\n",
" thrust_source='../../data/rockets/defiance/Thrust_curve.csv',\n",
" thrust_source=\"../../data/rockets/defiance/Thrust_curve.csv\",\n",
" dry_mass=13.832,\n",
" dry_inertia=(1.801, 1.801, 0.0305),\n",
" center_of_dry_mass_position=780 / 1000,\n",
Expand All @@ -167,9 +168,9 @@
" grain_density=920,\n",
" nozzle_radius=0.0447,\n",
" throat_radius=0.0234,\n",
" interpolation_method='linear',\n",
" interpolation_method=\"linear\",\n",
" grains_center_of_mass_position=0.377,\n",
" coordinate_system_orientation='nozzle_to_combustion_chamber',\n",
" coordinate_system_orientation=\"nozzle_to_combustion_chamber\",\n",
")\n",
"\n",
"hybrid_motor.add_tank(tank=oxidizer_tank, position=2.2)"
Expand Down Expand Up @@ -205,9 +206,9 @@
" # inertia = (180.142, 180.142, 0.262),\n",
" inertia=(94.14, 94.14, 0.09),\n",
" center_of_mass_without_motor=3.29,\n",
" power_off_drag='../../data/rockets/defiance/DragCurve.csv',\n",
" power_on_drag='../../data/rockets/defiance/DragCurve.csv',\n",
" coordinate_system_orientation='tail_to_nose',\n",
" power_off_drag=\"../../data/rockets/defiance/DragCurve.csv\",\n",
" power_on_drag=\"../../data/rockets/defiance/DragCurve.csv\",\n",
" coordinate_system_orientation=\"tail_to_nose\",\n",
")\n",
"\n",
"defiance.add_motor(hybrid_motor, position=0.2)\n",
Expand All @@ -220,10 +221,10 @@
"\n",
"defiance.add_tail(top_radius=0.07, bottom_radius=0.064, length=0.0597, position=0.1)\n",
"\n",
"defiance.add_parachute(name='main', cd_s=2.2, trigger=305, sampling_rate=100, lag=0)\n",
"defiance.add_parachute(name=\"main\", cd_s=2.2, trigger=305, sampling_rate=100, lag=0)\n",
"\n",
"defiance.add_parachute(\n",
" name='drogue', cd_s=1.55, trigger='apogee', sampling_rate=100, lag=0\n",
" name=\"drogue\", cd_s=1.55, trigger=\"apogee\", sampling_rate=100, lag=0\n",
")"
]
},
Expand Down
9 changes: 3 additions & 6 deletions docs/examples/erebus_flight_sim.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from rocketpy import Function, Environment, Flight, Rocket, SolidMotor\n",
"from rocketpy.motors import CylindricalTank, SolidMotor\n",
"from rocketpy.motors.tank import MassFlowRateBasedTank\n",
"\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from rocketpy import Environment, Flight, Function, Rocket, SolidMotor\n",
"\n",
"plt.style.use(\"seaborn-v0_8-colorblind\")"
]
},
Expand Down Expand Up @@ -384,7 +382,6 @@
"source": [
"from rocketpy.simulation.flight_data_importer import FlightDataImporter\n",
"\n",
"\n",
"columns_map = {\n",
" \"t\": \"time\",\n",
" \"alt\": \"altitude\",\n",
Expand Down
Loading
0