Skip to content

Replace string annotations with PEP 563 postponed evaluation - #177

Open
vhdl-s-claude-bot[bot] wants to merge 2 commits into
devfrom
claude/postponed-annotations
Open

Replace string annotations with PEP 563 postponed evaluation#177
vhdl-s-claude-bot[bot] wants to merge 2 commits into
devfrom
claude/postponed-annotations

Conversation

@vhdl-s-claude-bot

Copy link
Copy Markdown

Breaking Changes

  • ⚠️ Annotations in 13 modules are no longer evaluated at definition time. Those modules carry
    from __future__ import annotations, so on Python 3.11-3.13 SomeClass.__annotations__ yields strings
    where it previously yielded type objects; on Python 3.14 (PEP 649) they are
    computed lazily and read as before. Code introspecting these classes at runtime must resolve them itself with
    typing.get_type_hints(SomeClass), which works on every supported version.

    Worth knowing downstream: pyGHDL.dom builds this model, and VHDLDomain renders it. Neither reads
    __annotations__ today, so neither is affected - but that is the property to check if either starts to.

Changes

  • All 210 annotations written as string literals are plain annotations now:
    Nullable[Symbol] instead of Nullable["Symbol"].

    128 of them are genuine forward references, which is the highest proportion in the workspace so far - a
    language model is full of mutually recursive classes, and every one of them needed quoting before. That is also
    why the future import is required rather than cosmetic: Python 3.11-3.13 evaluate annotations eagerly and would
    raise NameError at import time without it.

    Verified by importing every module with /usr/bin/python3.13 - the interpreter that actually evaluates them
    eagerly - as well as under 3.14, plus CheckAnnotations forcing PEP 649 evaluation.

  • Each import section is grouped - future import, standard library, third-party, own package - with one empty line
    between the groups that exist and a single import column shared across them, matching the layout settled in
    pyTooling.

Union[...] annotations are untouched and are not part of this pull-request.


Related Issues and Pull-Requests

All 210 annotations written as string literals are plain annotations
now, and the 13 affected modules carry
'from __future__ import annotations'.

128 of them are genuine forward references - this model is full of
mutually recursive classes - so the future import is what makes the
change safe: Python 3.11-3.13 evaluate annotations eagerly and would
raise NameError at import time without it. Verified by importing every
module with /usr/bin/python3.13 as well as under 3.14.

Each import section is grouped - future, standard library, third-party,
own package - with one empty line between the groups and a single
'import' column across them.

Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
@codacy-production

codacy-production Bot commented Aug 21, 2026

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 25 high · 1 medium

Alerts:
⚠ 26 issues (≤ 0 issues of at least minor severity)

Results:
26 new issues

Category Results
ErrorProne 25 high
Complexity 1 medium

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

🟢 Coverage 79.06% diff coverage · -53.09% coverage variation

Metric Results
Coverage variation -53.09% coverage variation
Diff coverage 79.06% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (98ac5cd) Report Missing Report Missing Report Missing
Head commit (2f168fd) 4415 (-804) 1582 (-3059) 35.83% (-53.09%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#177) 234 185 79.06%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

1 Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.05983% with 49 lines in your changes missing coverage. Please review.
✅ Project coverage is 35.78%. Comparing base (98ac5cd) to head (2f168fd).

Files with missing lines Patch % Lines
pyVHDLModel/__init__.py 2.32% 42 Missing ⚠️
pyVHDLModel/Concurrent.py 12.50% 7 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##              dev     #177       +/-   ##
===========================================
- Coverage   87.14%   35.78%   -51.36%     
===========================================
  Files          24       16        -8     
  Lines        5219     4415      -804     
  Branches      446      407       -39     
===========================================
- Hits         4548     1580     -2968     
- Misses        578     2833     +2255     
+ Partials       93        2       -91     
Flag Coverage Δ
unittests 35.78% <79.05%> (-51.36%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Carried over from the review of pyEDAA.OutputFilter#103: the grouping
script came from the pyTooling repository, where 'pyTooling' *is* the
own package, so it sorted pyTooling into the own-package group and
pyVHDLModel into third-party - the wrong way round.

Sections are: future import, standard library, third-party (pyTooling),
own package (pyVHDLModel).

Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
@vhdl-s-claude-bot

Copy link
Copy Markdown
Author

Carried over from your review of pyEDAA.OutputFilter#103: this pull-request had the same defect, so I fixed it here too rather than wait for you to find it twice.

The grouping script came from the pyTooling repository, where pyTooling is the own package, so it sorted pyTooling into the own-package group and pyVHDLModel into third-party. Now:

from __future__            import annotations

from enum                  import Flag, auto
from typing                import Any, Optional as Nullable, Iterable, List, Dict, Mapping

from pyTooling.Decorators  import export, readonly
from pyTooling.MetaClasses import ExtendedType

from pyVHDLModel.Base      import Range
from pyVHDLModel.Name      import Name, AllName

Re-verified: 465 unit tests pass, alignment is clean, and every module still imports under /usr/bin/python3.13, which is the interpreter that evaluates the annotations eagerly.

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