Title: Modernize annotation usage in libregrtest · Issue #156402 · python/cpython · GitHub
Open Graph Title: Modernize annotation usage in libregrtest · Issue #156402 · python/cpython
X Title: Modernize annotation usage in libregrtest · Issue #156402 · python/cpython
Description: Bug description: Lib/test/libregrtest/results.py imports TYPE_CHECKING only to guard a type-only import: from typing import TYPE_CHECKING if TYPE_CHECKING: from xml.etree.ElementTree import Element Now that explicit lazy imports are avai...
Open Graph Description: Bug description: Lib/test/libregrtest/results.py imports TYPE_CHECKING only to guard a type-only import: from typing import TYPE_CHECKING if TYPE_CHECKING: from xml.etree.ElementTree import Element...
X Description: Bug description: Lib/test/libregrtest/results.py imports TYPE_CHECKING only to guard a type-only import: from typing import TYPE_CHECKING if TYPE_CHECKING: from xml.etree.ElementTree import Element...
Opengraph URL: https://github.com/python/cpython/issues/156402
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Modernize annotation usage in libregrtest","articleBody":"### Bug description:\n\n`Lib/test/libregrtest/results.py` imports `TYPE_CHECKING` only to guard a type-only import:\n\n```python\nfrom typing import TYPE_CHECKING\n\nif TYPE_CHECKING:\n from xml.etree.ElementTree import Element\n```\n\nNow that explicit lazy imports are available, this can be replaced with:\n\n```python\nlazy from xml.etree.ElementTree import Element\n```\n\nThe stringized `list['Element']` annotation can then become `list[Element]`. This keeps `xml.etree.ElementTree` from being imported eagerly while making the annotation name available at runtime.\n\n`Lib/test/libregrtest/mypy.ini` should also target Python 3.15, following the approach used for pyrepl in gh-149985 and gh-149992.\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\n_No response_\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-156403\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/ashm-dev","@type":"Person","name":"ashm-dev"},"datePublished":"2026-08-26T07:04:52Z","url":"https://github.com/python/cpython/issues/156402"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:31770cfa-14a2-e09f-548c-6eec81343f2f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E1C2:F7C4C:3442DCD:45F76F5:6B020954 |
| html-safe-nonce | cdf3a96b0876fbb7dbd10e4e1f8605d06257e749007e7f87ea1c95e259617d63 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMUMyOkY3QzRDOjM0NDJEQ0Q6NDVGNzZGNTo2QjAyMDk1NCIsInZpc2l0b3JfaWQiOiI2MTQzMTE2MDkzODg2MzI0MDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5206344d376772184127fd7c333582e953fc302f59dbb36cdd5602e4d1fca038 |
| hovercard-subject-tag | issue:5254278566 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/156402/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dd2cd86b799725f160ffe19b3b24d9c8fdf21f08590f6c8a515eb12cc52e6894/python/cpython/issues/156402 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dd2cd86b799725f160ffe19b3b24d9c8fdf21f08590f6c8a515eb12cc52e6894/python/cpython/issues/156402 |
| og:image:alt | Bug description: Lib/test/libregrtest/results.py imports TYPE_CHECKING only to guard a type-only import: from typing import TYPE_CHECKING if TYPE_CHECKING: from xml.etree.ElementTree import Element... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ashm-dev |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width