Skip to content

fix(parsers): import UniversalConcept for annotations in C# and MATLAB mappings - #432

Merged
HananKavitzAmat merged 1 commit into
chunkhound:mainfrom
WynandVStaden:fix/f821-universalconcept-annotations
Oct 6, 2026
Merged

HananKavitzAmat merged 1 commit into
chunkhound:mainfrom
WynandVStaden:fix/f821-universalconcept-annotations

Conversation

@WynandVStaden

Copy link
Copy Markdown
Contributor

Why

ruff check chunkhound (the lint step in CONTRIBUTING) reports nine F821 undefined-name errors, all for UniversalConcept in parsers/mappings/csharp.py and parsers/mappings/matlab.py. Both modules use the name in quoted parameter annotations but only import it inside function bodies, so linters and mypy cannot resolve it. These are the only non-cosmetic items in the baseline described in #349, and they make the lint step harder to use because a contributor cannot tell new violations from existing ones.

This is option 1 from #349 ("just the F821"), which @HananKavitzAmat asked to start with. It does not touch the cosmetic violations or CI.

Change

Add a TYPE_CHECKING-only import of UniversalConcept to both modules, the same pattern parsers/mappings/base.py already uses. The import never runs at runtime, so behaviour is unchanged and no import cycle is introduced.

Verification (Windows 11, Python 3.14, native extension built locally)

Check Before After
ruff check chunkhound --select F821 9 errors 0
mypy chunkhound 1013 errors in 93 files 1004 errors in 92 files
ruff format --check on both files clean clean
  • pytest tests/test_smoke.py: 14 passed.
  • pytest tests/test_csharp_mapping.py tests/test_parser_mappings_import.py: 42 passed.
  • pytest tests/: 4980 passed, 128 skipped. The remaining failures on my machine are not related to these files: the tests/site tests error because I did not build the site, one symlink test needs a Windows privilege my account lacks, and several MCP stdio startup tests hit their 5 s timeouts. I re-ran those on unmodified main and they fail or flake the same way there.

Refs #349

…B mappings

csharp.py and matlab.py annotate method parameters with the string
"UniversalConcept" but only import the name inside function bodies, so
ruff reports nine F821 undefined-name errors and mypy reports nine
name-defined errors for the two modules.

Add a TYPE_CHECKING-only import, the same pattern mappings/base.py already
uses. Nothing changes at runtime.

Refs chunkhound#349
@HananKavitzAmat
HananKavitzAmat self-requested a review October 6, 2026 08:40
@HananKavitzAmat

Copy link
Copy Markdown
Collaborator

Looks Good to me. Merging!

@HananKavitzAmat
HananKavitzAmat added this pull request to the merge queue Oct 6, 2026
Merged via the queue into chunkhound:main with commit 181c0fe Oct 6, 2026
23 checks passed
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