Skip to content

Fix ruff errors and modernize project config and build - #205

Merged
stdavis merged 5 commits into
mainfrom
fix/fix-new-ruff-errors
Aug 7, 2026
Merged

Fix ruff errors and modernize project config and build#205
stdavis merged 5 commits into
mainfrom
fix/fix-new-ruff-errors

Conversation

@stdavis

@stdavis stdavis commented Aug 7, 2026

Copy link
Copy Markdown
Member

A recent update to Ruff caused some new errors. This addresses them.

A recent update to Ruff caused some new errors. This addresses them.
@stdavis
stdavis enabled auto-merge (rebase) August 7, 2026 15:50
@stdavis
stdavis requested a lite review from Copilot August 7, 2026 15:50
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.96970% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 96.17%. Comparing base (f87f4c5) to head (e660de3).
⚠️ Report is 159 commits behind head on main.

Files with missing lines Patch % Lines
src/palletjack/load.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #205      +/-   ##
==========================================
+ Coverage   94.52%   96.17%   +1.65%     
==========================================
  Files           7        6       -1     
  Lines        1133     1361     +228     
  Branches      148      154       +6     
==========================================
+ Hits         1071     1309     +238     
+ Misses         52       43       -9     
+ Partials       10        9       -1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the codebase to satisfy new Ruff lint findings after a Ruff upgrade, primarily by tightening exception handling patterns, simplifying control flow, and making time handling explicit/consistent.

Changes:

  • Adds targeted noqa annotations for intentional broad exceptions and modernizes raise usage to preserve tracebacks.
  • Refactors small logic/style patterns flagged by Ruff (flattened conditionals, generator usage, assertion call fixes).
  • Updates datetime usage in runtime and tests (UTC-aware timestamps) and tweaks packaging version-loading in setup.py.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/test_utils.py Lint-driven test adjustments (noqa annotations, simplified bool mocks, UTC-aware date expectations, formatting).
tests/test_transform.py Import ordering tweak to satisfy linting.
tests/test_extract.py Test cleanups (assertion call fix, context manager formatting, range simplifications, UTC-aware datetime usage, expected exception type).
src/palletjack/utils.py Lint fixes and small refactors (bare raise, iteration simplification, expression assignment, chunking simplification, UTC-aware layer naming).
src/palletjack/transform.py Uses UTC-aware timing for logging duration.
src/palletjack/load.py Uses UTC-aware timing; improves exception logging via .exception() usage.
src/palletjack/extract.py Minor refactors, adds UTC-aware datetime operations for token validation, refines raised exception type for unexpected JSON.
setup.py Replaces exec-based version extraction with runpy.run_path.
README.md Normalizes quotes in example snippets.
docs/README.md Normalizes quotes in logging examples.
docs/examples.py Minor formatting and narrows example exception type.

Comment thread setup.py Outdated
stdavis added 3 commits August 7, 2026 10:01
So that the PR upload comparison is up-to-date
Also add python version requirement

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated no new comments.

Suppressed comments (4)

tests/test_utils.py:1896

  • Same flakiness risk here: expected_out_layer is derived from a fresh now() call, but save_to_gdb() computes its own now() internally. Freezing palletjack.utils.datetime.datetime.now in the test avoids intermittent failures at a UTC date boundary.
        expected_out_path = Path("foo", "backup.gdb")
        expected_out_layer = f"table_{datetime.datetime.now(datetime.UTC).strftime('%Y_%m_%d')}"

tests/test_utils.py:1922

  • This test can also be flaky around a UTC date rollover for the same reason: expected_error is computed using a now() call that can disagree with the now() inside save_to_gdb(). Freeze the time in palletjack.utils to ensure a stable expected message.
        gdb_path = Path("/foo/bar/backup.gdb")
        date = datetime.datetime.now(datetime.UTC).strftime("%Y_%m_%d")
        expected_error = f"Error writing flayer_{date} to {gdb_path}. Verify {gdb_path.parent} exists and is writable."

tests/test_utils.py:1879

  • This test can be flaky around a UTC date rollover because it calls datetime.datetime.now(datetime.UTC) to build expected_out_layer, and save_to_gdb() independently calls now() again. If the date changes between those calls, the assertion can fail intermittently. Patch palletjack.utils.datetime.datetime.now to a fixed value within the test so both sides use the same timestamp.

This issue also appears in the following locations of the same file:

  • line 1894
  • line 1920
        expected_out_path = Path("foo", "backup.gdb")
        expected_out_layer = f"flayer_{datetime.datetime.now(datetime.UTC).strftime('%Y_%m_%d')}"

pyproject.toml:9

  • With src/palletjack/version.py removed, there is no longer a programmatic version constant (e.g., palletjack.version.__version__). If this was part of the public API, consider restoring a compatibility shim (for example, a small version.py that reads from importlib.metadata) and/or exporting __version__ from palletjack.__init__ to avoid breaking downstream imports.
[project]
name = "ugrc-palletjack"
version = "6.0.4"
description = "Updating AGOL feature services with data from external tables."
readme = { file = "README.md", content-type = "text/markdown" }

@stdavis
stdavis requested a review from acneville August 7, 2026 16:37
@stdavis stdavis changed the title chore: fix new ruff errors Fix ruff errors and modernize project config and build Aug 7, 2026
Comment thread pyproject.toml Outdated
acneville
acneville previously approved these changes Aug 7, 2026
@stdavis
stdavis disabled auto-merge August 7, 2026 18:40
@stdavis
stdavis merged commit 7518af5 into main Aug 7, 2026
5 checks passed
@stdavis
stdavis deleted the fix/fix-new-ruff-errors branch August 7, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants