Skip to content

AnniversariesGramplet: import WindowActiveError#843

Merged
GaryGriffin merged 1 commit into
gramps-project:maintenance/gramps60from
eduralph:fix/anniversariesgramplet-add-missing-import
May 13, 2026
Merged

AnniversariesGramplet: import WindowActiveError#843
GaryGriffin merged 1 commit into
gramps-project:maintenance/gramps60from
eduralph:fix/anniversariesgramplet-add-missing-import

Conversation

@eduralph

@eduralph eduralph commented May 9, 2026

Copy link
Copy Markdown
Contributor

Summary

AnniversariesGramplet/AnniversariesGramplet.py:103 references WindowActiveError in an except clause but never imports it. Ruff (rule F821) flags this:

F821 Undefined name `WindowActiveError`
   --> AnniversariesGramplet/AnniversariesGramplet.py:103:20
    |
101 |                 event = self.dbstate.db.get_event_from_handle(handle)
102 |                 EditEvent(self.dbstate, self.uistate, [], event)
103 |             except WindowActiveError:
    |                    ^^^^^^^^^^^^^^^^^
104 |                 pass
    |

The exception is raised by gramps.gui.editors.EditEvent when the editor is already open for the same handle; WindowActiveError lives in gramps.gen.errors. Without the import, the except clause would trigger NameError if an editor were already open — a real (if rare) runtime bug masked today only because that path is uncommon.

Fix

Add the missing import alongside the other gramps.gen.* imports:

 from gramps.gen.config import config
+from gramps.gen.errors import WindowActiveError
 from gramps.gui.editors import EditEvent

One-line change, no behavioural impact under normal use; fixes the NameError on the active-editor path.

Verification

  • ruff check --select=E9,F63,F7,F82 --no-fix --exclude='*.gpr.py' AnniversariesGramplet/ → "All checks passed!" (was 1 F821).
  • python3 -m py_compile AnniversariesGramplet/AnniversariesGramplet.py exits 0.
  • Sweep across the entire addons-source tree confirms exactly one F821 was removed (from 78 → 77 sites) — no other addon affected.

Scope

Per addons-source convention, one PR per addon directory. This is the first of an upstream-friendly per-addon series clearing the lint backlog (the same set PR #820's body originally enumerated). Each subsequent PR will be similarly minimal and addon-scoped.

🤖 Generated with Claude Code

`AnniversariesGramplet/AnniversariesGramplet.py:103` references
`WindowActiveError` in an `except` clause but never imports it. Ruff
(`F821`) flags this:

    F821 Undefined name `WindowActiveError`
       --> AnniversariesGramplet/AnniversariesGramplet.py:103:20

The exception is raised by `gramps.gui.editors.EditEvent` when the
editor is already open for the same handle; `WindowActiveError` lives
in `gramps.gen.errors`. Without the import, the `except` clause would
trigger `NameError` if an editor were already open — masked today only
because that path is rare.

Add the missing import alongside the other `gramps.gen.*` imports.
One-line change, no behavioural impact under normal use; fixes the
`NameError` on the active-editor path.

Verified locally with `ruff check --select=E9,F63,F7,F82 --no-fix
--exclude='*.gpr.py' AnniversariesGramplet/` (now passes) and
`python3 -m py_compile`.
@eduralph

eduralph commented May 9, 2026

Copy link
Copy Markdown
Contributor Author

@GaryGriffin - this is the first of 70 linting issues found in 27 add-ons. I didn't want to dump it all on you right away and happy to space it out the way you would like best. alternatively, I can do all 26 PRs at one go and you can merge as you see fit.

@GaryGriffin

Copy link
Copy Markdown
Member

I am fine with 26 more PRs. I will also cherry pick each to gramps61. I may not wait my traditional week before merging.

@GaryGriffin
GaryGriffin merged commit 60bd840 into gramps-project:maintenance/gramps60 May 13, 2026
eduralph added a commit to eduralph/addons-source that referenced this pull request May 19, 2026
…ps60

Drops the lint job's continue-on-error: true (and its TODO comment),
making ruff E9/F63/F7/F82 a blocking gate per the comment's own
instruction.

The ruff backlog the comment guarded against was cleared by 24 PRs
(gramps-project#843 + gramps-project#847-gramps-project#869) merged into maintenance/gramps60 between 2026-05-12
and 2026-05-18. Verified locally:

    pipx run ruff check --select=E9,F63,F7,F82 \
        --no-fix --exclude='*.gpr.py' .

on `gramps-project/addons-source:maintenance/gramps60` reports
"All checks passed!".

Other continue-on-error gates in this workflow (addon-structure,
compile-check, integration) each guard their own backlogs and stay
non-blocking until those clear separately.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
eduralph added a commit to eduralph/addons-source that referenced this pull request May 19, 2026
…ared

Drops continue-on-error: true (and the TODO comments) from both
unit-test jobs. They were guarding against "currently-broken addon
unit modules (import failures, stale API usage)" that have since been
fixed by the merged plugin-registration / dep-declaration round
(gramps-project#875 WordleGramplet, gramps-project#876 SourceReferences, gramps-project#878 EditExifMetadata,
gramps-project#879 MongoDB, gramps-project#880 PhotoTaggingGramplet, gramps-project#869 SurnameMappingGramplet,
gramps#2299 ClipboardGramplet) plus the lint backlog (gramps-project#843, gramps-project#847-gramps-project#869).

Verified by the most recent fork CI run on
eduralph/addons-source:maintenance/gramps60 (sha 8aabdd4, 2026-05-18):
both Unit Tests (Linux) and Unit Tests (Windows) reported success.

Also clears two stale comments that referenced the removed flag:
- unit-test-linux's "Run per-addon unit tests" step: drop the
  trailing "Falls silently under continue-on-error." sentence.
- integration's requires_mod-validate step: collapse the now-moot
  "this is the blocking copy" rationale to a plain pointer at
  unit-test-linux.

The lone remaining continue-on-error is on addon-structure (line 70),
gated by the po/template.pot backlog. PRs gramps-project#838-gramps-project#841 were closed
without merge; per Eduard's call the po/template.pot check stays
non-blocking for now.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@eduralph
eduralph deleted the fix/anniversariesgramplet-add-missing-import branch June 7, 2026 16:41
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.

2 participants