Skip to content

Fix pycroscope findings - #83

Merged
JelleZijlstra merged 2 commits into
masterfrom
codex/fix-pycroscope-findings
Aug 13, 2026
Merged

Fix pycroscope findings#83
JelleZijlstra merged 2 commits into
masterfrom
codex/fix-pycroscope-findings

Conversation

@JelleZijlstra

@JelleZijlstra JelleZijlstra commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • tighten applicator, lint, and test-fixture types exposed while validating pycroscope#519
  • add narrow suppressions for two inherited generic calls where pycroscope gives method-local TypeVar identities to the same class type parameter
  • correctly count duplicate parameterless AuxiliaryName and OriginalCitation ADT tags, whose constructors are singleton values rather than classes

Root cause

Most findings came from dynamic SimpleNamespace fixtures or runtime invariants that were not made explicit to the checker. The duplicate-tag bug was separate: check_tags() counts type(tag), but looked up the two parameterless ADT variants by singleton value, so their duplicate counts always appeared as zero.

Validation

  • the full taxonomy/ tree checks cleanly with the pycroscope PR head
  • repository-wide pre-commit hooks pass
  • 186 focused applicator and model-lint tests pass

The PR's pycroscope and lint workflows now pass. The test workflow still reproduces the missing-configuration failures already present on master at the base commit.

Tighten typing around applicator helpers, protocol fixtures, lint helpers, and ADT fields so the current pycroscope main branch checks the taxonomy package cleanly. Also fix duplicate detection for parameterless classification-entry tags and add a regression test.
Comment thread taxonomy/applicator/test_generic.py Outdated
model: type[BaseModel], values: Mapping[str, object]
) -> BaseModel:
obj = model.virtual(**values)
obj = cast(Location, model.virtual(**values))

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This cast seems wrong, should this be refactored to always only return a Location, or maybe do an isinstance check before appending to created?

Comment thread taxonomy/applicator/test_generic.py Outdated
model: type[BaseModel], values: Mapping[str, object]
) -> BaseModel:
obj = model.virtual(**values)
obj = cast(Location, model.virtual(**values))

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

same

Comment thread taxonomy/db/models/name/test_lint.py Outdated
def test_take_over_name_issue_uses_explicit_fields_and_tag_removal() -> None:
citation = SimpleNamespace(
parent=None, author_tags=("Author",), year="1900", issupplement=lambda: False
citation = cast(

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Can this use a virtual Article object instead of SimpleNamespace?

Use runtime narrowing in the generic applicator tests, replace the dynamic article fixture with a virtual model, and link the two upstream pycroscope issues from their narrow workarounds.
@JelleZijlstra
JelleZijlstra merged commit 3ddb0fa into master Aug 13, 2026
5 of 7 checks passed
@JelleZijlstra
JelleZijlstra deleted the codex/fix-pycroscope-findings branch August 13, 2026 05:31
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.

1 participant