Replace string annotations with PEP 563 postponed evaluation - #177
Replace string annotations with PEP 563 postponed evaluation#177vhdl-s-claude-bot[bot] wants to merge 2 commits into
Conversation
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>
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| ErrorProne | 25 high |
| Complexity | 1 medium |
🟢 Metrics 0 complexity · 0 duplication
Metric Results Complexity 0 Duplication 0
🟢 Coverage 79.06% diff coverage · -53.09% coverage variation
Metric Results Coverage variation ✅ -53.09% coverage variation Diff coverage ✅ 79.06% diff coverage 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 Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
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>
|
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 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, AllNameRe-verified: 465 unit tests pass, alignment is clean, and every module still imports under |
Breaking Changes
from __future__ import annotations, so on Python 3.11-3.13SomeClass.__annotations__yields stringswhere 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.dombuilds this model, andVHDLDomainrenders 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 ofNullable["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
NameErrorat import time without it.Verified by importing every module with
/usr/bin/python3.13- the interpreter that actually evaluates themeagerly - as well as under 3.14, plus
CheckAnnotationsforcing 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
importcolumn shared across them, matching the layout settled inpyTooling.
Union[...]annotations are untouched and are not part of this pull-request.Related Issues and Pull-Requests