carsonfarmer / fastpair

FastPair: Data-structure for the dynamic closest-pair problem.
MIT License
12 stars 4 forks source link

utilizing `ruff` for formatting & linting – #20 #31

Closed jGaboardi closed 4 months ago

jGaboardi commented 4 months ago

utilizing ruff for formatting & linting – #20

jGaboardi commented 4 months ago

Running ruff check fastpair with the following rules (standard in the PySAL ecosystem):

lint.select = ["E", "F", "W", "I", "UP", "N", "B", "A", "C4", "SIM", "ARG"]

results in:

fastpair/__init__.py:2:1: UP009 [*] UTF-8 encoding declaration is unnecessary
fastpair/__init__.py:16:19: F401 `.base.FastPair` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
fastpair/base.py:2:1: UP009 [*] UTF-8 encoding declaration is unnecessary
fastpair/base.py:36:1: UP010 [*] Unnecessary `__future__` imports `absolute_import`, `division`, `print_function` for target Python version
fastpair/base.py:36:1: I001 [*] Import block is un-sorted or un-formatted
fastpair/base.py:38:22: F401 [*] `operator.itemgetter` imported but unused
fastpair/base.py:46:7: N801 Class name `attrdict` should use CapWords convention
fastpair/base.py:50:14: UP008 Use `super()` instead of `super(__class__, self)`
fastpair/base.py:54:16: UP004 [*] Class `FastPair` inherits from `object`
fastpair/base.py:77:23: C408 Unnecessary `list` call (rewrite as a literal)
fastpair/base.py:101:21: F841 Local variable `res` is assigned to but never used
fastpair/base.py:119:16: E713 [*] Test for membership should be `not in`
fastpair/base.py:120:28: UP032 [*] Use f-string instead of `format` call
fastpair/base.py:124:16: E713 [*] Test for membership should be `not in`
fastpair/base.py:125:28: UP032 [*] Use f-string instead of `format` call
fastpair/test/test_fastpair.py:2:1: UP009 [*] UTF-8 encoding declaration is unnecessary
fastpair/test/test_fastpair.py:13:1: UP010 [*] Unnecessary `__future__` imports `absolute_import`, `division`, `print_function` for target Python version
fastpair/test/test_fastpair.py:13:1: I001 [*] Import block is un-sorted or un-formatted
fastpair/test/test_fastpair.py:17:44: F401 [*] `itertools.groupby` imported but unused
fastpair/test/test_fastpair.py:23:32: F401 [*] `scipy.unique` imported but unused
fastpair/test/test_fastpair.py:66:21: B905 [*] `zip()` without an explicit `strict=` parameter
fastpair/test/test_fastpair.py:82:5: N802 Function name `PointSet` should be lowercase
fastpair/test/test_fastpair.py:99:26: N803 Argument name `PointSet` should be lowercase
fastpair/test/test_fastpair.py:106:24: N803 Argument name `PointSet` should be lowercase
fastpair/test/test_fastpair.py:117:24: N803 Argument name `PointSet` should be lowercase
fastpair/test/test_fastpair.py:130:24: N803 Argument name `PointSet` should be lowercase
fastpair/test/test_fastpair.py:137:29: N803 Argument name `PointSet` should be lowercase
fastpair/test/test_fastpair.py:144:42: N803 Argument name `PointSet` should be lowercase
fastpair/test/test_fastpair.py:153:38: N803 Argument name `PointSet` should be lowercase
fastpair/test/test_fastpair.py:171:44: N803 Argument name `PointSet` should be lowercase
fastpair/test/test_fastpair.py:179:9: E741 Ambiguous variable name: `l`
fastpair/test/test_fastpair.py:187:28: N803 Argument name `PointSet` should be lowercase
fastpair/test/test_fastpair.py:212:33: N803 Argument name `PointSet` should be lowercase
fastpair/test/test_fastpair.py:223:9: E741 Ambiguous variable name: `l`
fastpair/test/test_fastpair.py:224:9: F841 Local variable `res` is assigned to but never used
fastpair/test/test_fastpair.py:225:9: F841 Local variable `neigh` is assigned to but never used
fastpair/test/test_fastpair.py:270:25: N803 Argument name `PointSet` should be lowercase
fastpair/test/test_fastpair.py:280:13: F841 Local variable `myitem` is assigned to but never used
fastpair/test/test_fastpair.py:290:45: N803 Argument name `PointSet` should be lowercase
fastpair/test/test_fastpair.py:298:9: F841 Local variable `res` is assigned to but never used

There are actually far fewer linting issues than I anticipated and - from what I can tell - all are trivial fixes. Great job at writing future-proof code @carsonfarmer !

codecov-commenter commented 4 months ago

Codecov Report

Attention: Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 99.2%. Comparing base (3d082b4) to head (7383b93).

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/carsonfarmer/fastpair/pull/31/graphs/tree.svg?width=650&height=150&src=pr&token=9VQNETZHJX&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Carson+Farmer)](https://app.codecov.io/gh/carsonfarmer/fastpair/pull/31?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Carson+Farmer) ```diff @@ Coverage Diff @@ ## main #31 +/- ## ======================================== - Coverage 100.0% 99.2% -0.8% ======================================== Files 2 2 Lines 127 125 -2 ======================================== - Hits 127 124 -3 - Misses 0 1 +1 ``` | [Files](https://app.codecov.io/gh/carsonfarmer/fastpair/pull/31?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Carson+Farmer) | Coverage Δ | | |---|---|---| | [fastpair/\_\_init\_\_.py](https://app.codecov.io/gh/carsonfarmer/fastpair/pull/31?src=pr&el=tree&filepath=fastpair%2F__init__.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Carson+Farmer#diff-ZmFzdHBhaXIvX19pbml0X18ucHk=) | `100.0% <ø> (ø)` | | | [fastpair/base.py](https://app.codecov.io/gh/carsonfarmer/fastpair/pull/31?src=pr&el=tree&filepath=fastpair%2Fbase.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Carson+Farmer#diff-ZmFzdHBhaXIvYmFzZS5weQ==) | `99.2% <91.7%> (-0.8%)` | :arrow_down: |