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

lint with F and B rules #1095

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

zacharyburnett
Copy link
Collaborator

@zacharyburnett zacharyburnett commented Feb 8, 2024

closes #1094

Issues 1 and 2 should be caught by B015 (and/or B018).

Issue 4 might be caught by F821.

It is possible that even issue 3 might be caught but I don't see a rule when I glanced through: https://docs.astral.sh/ruff/rules/ that might apply.

In any case I suggest we explicitly turn on Pyflakes (F) and Bugbear (B), fixing all the issues they find as those are both recommended rule sets.

Originally posted by @WilliamJamieson in #1094 (comment)

Checklist

  • added entry in CHANGES.rst under the corresponding subsection
  • updated relevant tests
  • updated relevant documentation
  • updated relevant milestone(s)
  • added relevant label(s)
  • ran regression tests, post a link to the Jenkins job below. How to run regression tests on a PR

@zacharyburnett zacharyburnett self-assigned this Feb 8, 2024
@github-actions github-actions bot added testing dependencies Pull requests that update a dependency file associations labels Feb 8, 2024
@zacharyburnett
Copy link
Collaborator Author

ruff check .
romancal/associations/association_io.py:69:13: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
romancal/associations/association_io.py:135:13: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
romancal/associations/lib/diff.py:270:9: B007 Loop control variable `left_idx` not used within loop body
romancal/associations/lib/diff.py:272:13: B007 Loop control variable `right_idx` not used within loop body
romancal/associations/lib/dms_base.py:422:17: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
romancal/associations/lib/dms_base.py:665:9: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
romancal/associations/lib/keyvalue_registry.py:105:17: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
romancal/associations/lib/product_utils.py:122:5: B028 No explicit `stacklevel` keyword argument found
romancal/associations/lib/product_utils.py:124:9: B028 No explicit `stacklevel` keyword argument found
romancal/associations/lib/product_utils.py:129:9: B028 No explicit `stacklevel` keyword argument found
romancal/associations/lib/product_utils.py:141:9: B007 Loop control variable `product_name` not used within loop body
romancal/associations/lib/rules_level2.py:153:13: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
romancal/associations/registry.py:139:13: B007 Loop control variable `name` not used within loop body
romancal/associations/registry.py:217:13: B007 Loop control variable `rule_name` not used within loop body
romancal/associations/tests/test_constraints.py:44:19: B007 Loop control variable `constraints` not used within loop body
romancal/associations/tests/test_constraints.py:245:9: B018 Found useless attribute access. Either assign it to a variable or remove it.
romancal/associations/tests/test_constraints.py:248:9: B018 Found useless attribute access. Either assign it to a variable or remove it.
romancal/datamodels/container.py:169:21: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
romancal/outlier_detection/outlier_detection.py:129:17: B007 Loop control variable `i` not used within loop body
romancal/photom/photom.py:104:9: B028 No explicit `stacklevel` keyword argument found
romancal/pipeline/exposure_pipeline.py:195:21: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
romancal/resample/resample_utils.py:145:13: B028 No explicit `stacklevel` keyword argument found
romancal/resample/tests/test_resample_step.py:66:9: B018 Found useless expression. Either assign it to a variable or remove it.
romancal/scripts/static_preview.py:19:9: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
romancal/skymatch/tests/test_skymatch.py:74:9: B008 Do not perform function call `np.random.default_rng` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
romancal/tweakreg/astrometric_utils.py:215:9: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
romancal/tweakreg/astrometric_utils.py:219:9: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
romancal/tweakreg/astrometric_utils.py:221:9: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
romancal/tweakreg/tests/test_astrometric_utils.py:336:25: B008 Do not perform function call `u.Quantity` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
romancal/tweakreg/tests/test_tweakreg.py:212:25: B008 Do not perform function call `u.Quantity` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
Found 30 errors.
No fixes available (4 hidden fixes can be enabled with the `--unsafe-fixes` option).

Copy link

codecov bot commented Feb 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (6c9b6c7) 76.81% compared to head (92f8866) 76.81%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1095   +/-   ##
=======================================
  Coverage   76.81%   76.81%           
=======================================
  Files         105      105           
  Lines        7048     7048           
=======================================
  Hits         5414     5414           
  Misses       1634     1634           
Flag Coverage Δ *Carryforward flag
nightly 62.99% <ø> (ø) Carriedforward from 6c9b6c7

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sonarqube checks
1 participant