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

pre-commit rules remove unused variables but does not delete the object assigned to the variable #77

Open
dakotaramos opened this issue Jan 24, 2025 · 0 comments
Labels
bug Something isn't working low priority

Comments

@dakotaramos
Copy link
Collaborator

dakotaramos commented Jan 24, 2025

pre-commit rules remove unused variables but does not delete the object assigned to that variable

During the testing process of PR #56 I discovered the pre-commit rules had deleted an unused variable but did not delete the subsequent code / object assigned to that variable. This resulted in error B018 Found useless attribute access. Either assign it to a variable or remove it.

How to reproduce

Original code lines in utilities.py:

battery_annual_energy_kwh = hopp_results["annual_energies"]["battery"]  # annual energy from battery (kWh)
battery_system_capacity_kwh = hopp_results["hybrid_plant"].battery.system_capacity_kwh  # battery rated capacity (kWh)

where the two variables were not used later in the code
run pre-commit run --file greenheart/tools/eco/utilities.py

Relevant output

greenheart/tools/eco/utilities.py:1479:5: B018 Found useless attribute access. Either assign it to a variable or remove it.
     |
1477 |     ]  # annual energy from solar (kWh)
1478 |     hopp_results["annual_energies"]["battery"]  # annual energy from battery (kWh)
1479 |     hopp_results["hybrid_plant"].battery.system_capacity_kwh  # battery rated capacity (kWh)
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B018
1480 |     wind_turbine_rating_MW = (
1481 |         hopp_config["technologies"]["wind"]["turbine_rating_kw"] / 1000

System Information

  • OS: <macOS 15.2>
  • Python version: <3.11.10>
  • GreenHEART version: <0.1.1>
@johnjasa johnjasa added bug Something isn't working low priority labels Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working low priority
Projects
None yet
Development

No branches or pull requests

2 participants