Skip to content

Remove the version checks around add_note() - #170

Open
eda-s-claude-bot[bot] wants to merge 1 commit into
devfrom
claude/drop-python310-guards
Open

Remove the version checks around add_note()#170
eda-s-claude-bot[bot] wants to merge 1 commit into
devfrom
claude/drop-python310-guards

Conversation

@eda-s-claude-bot

Copy link
Copy Markdown

Bug Fixes

  • All 36 Exception.add_note() call was wrapped in if version_info >= (3, 11):, so the note was attached only on
    Python 3.11 and newer. This package requires Python 3.11 or newer
    (setup.py: pythonVersions=("3.11", "3.12", "3.13", "3.14")), so the condition is always true and the guard is a
    leftover from supporting 3.10.

    ex = TypeError(f"Parameter 'name' is not of type 'str'.")
    ex.add_note(f"Got type '{getFullyQualifiedName(name)}'.")
    raise ex
  • The # pragma: no cover markers go with them: those lines were never covered because the false branch cannot be
    reached, and marking reachable code as uncoverable hides it from the coverage report.

Changes

  • from sys import version_info is dropped where nothing else used it.
  • ReportException also carried a polyfill: under Python <3.11 it declared __notes__ and implemented
    add_note() itself. That branch can no longer be taken, so the class is the plain base-exception it was meant to
    be - with the doc-string it never had.

Unit Tests

  • Unchanged: 157 passed with 65 subtests, plus 8 application tests.

Related Issues and Pull-Requests

  • Same cleanup in pyTooling (#277), pyEDAA.IPXACT and
    pyEDAA.ProjectModel, following a review comment in
    pyTooling#274: "pyTooling is Python 3.11+, so no version check
    is required."

…supported Python

'Exception.add_note()' was added in Python 3.11, and this package requires 3.11 or newer
(setup.py: pythonVersions=("3.11", "3.12", "3.13", "3.14")), so 'if version_info >= (3, 11):' is
always true. 36 guards removed, together with the now unused 'from sys import version_info' in two
modules.

'ReportException' also carried a polyfill: under Python <3.11 it declared '__notes__' and implemented
'add_note()' itself. That branch can no longer be taken, so the class is now the plain base-exception
it was meant to be - with the doc-string it never had.

The '# pragma: no cover' markers go with the guards - those lines were never covered, because the
false branch cannot be reached.

Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant