Skip to content

FIX: typing of ScopingPolicy members#427

Open
TTsangSC wants to merge 1 commit intopyutils:mainfrom
TTsangSC:scoping-policy-typing-fix
Open

FIX: typing of ScopingPolicy members#427
TTsangSC wants to merge 1 commit intopyutils:mainfrom
TTsangSC:scoping-policy-typing-fix

Conversation

@TTsangSC
Copy link
Copy Markdown
Collaborator

Closes #426.

  • CHANGELOG.rst
    Added entry
  • line_profiler/line_profiler.py::LineProfiler._add_namespace(...)
    Removed now-unnecessary typing.cast() in default arguments
  • line_profiler/line_profiler_utils.py
    • _StrEnum
      New alias which resolves:
      • Statically, always to enum.StrEnum
      • At the runtime, also thereto if available, and to _StrEnumBase otherwise
    • StringEnum
      Now "always" "statically" inheriting from _StrEnum to make things less confusing to the type-checker

@Erotemic
Copy link
Copy Markdown
Member

Looks like that HTTP Error 429: Too Many Requests issue is hitting us here too. We will need to fix that.

I remember this causing an issue when I was adding the refactoring the pyi files into inline typing. But hopefully this resolves it. Have you checked using ty check as well? I don't think I added ty to the lint checks on CI yet, but I plan to.

@TTsangSC
Copy link
Copy Markdown
Collaborator Author

The weird thing is that on pypa/cibuildwheel#2768 and other similar recent issues, the consensus seems to be that the request bug is limited to v2 and should be fixed by upgrading to v3 (example before, example after), but we've been running 3.1.2 all this time according to the logs.

A CIBW contributor pointed to GitHub's rate limiting as the culprit and linked to an announcement blog post about it, but thing is that said post was from mid-2025, and IDK why it's only hitting our (and the issue authors') CIs starting last week. Apparently the post mentioned requests without creds being limited, and I initially wondered if we needed to hook cibuildwheel up to something in the secrets to make it work. But I took a look at the other repos where the folks were like "thanks that fixed it", and they don't seem to have to jump through any such hoops.

Nope I haven't touched the uv ecosystem yet; probably should though since it seems to be gaining momentum.

CHANGELOG.rst
    Added entry

line_profiler/line_profiler.py::LineProfiler._add_namespace(...)
    Removed unnecessary `typing.cast()` in default arguments

line_profiler/line_profiler_utils.py
    _StrEnum
        New alias which resolves:
        - Statically, always to `enum.StrEnum`
        - At the runtime, also thereto if available, and to
          `_StrEnumBase` otherwise
    StringEnum
        Now always "statically" inheriting from `_StrEnum` to make
        things less confusing to the type-checker
@TTsangSC TTsangSC force-pushed the scoping-policy-typing-fix branch from 242fc57 to 6a5db86 Compare April 15, 2026 03:31
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.38%. Comparing base (60e928f) to head (6a5db86).
⚠️ Report is 36 commits behind head on main.

Files with missing lines Patch % Lines
line_profiler/line_profiler_utils.py 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #427      +/-   ##
==========================================
- Coverage   87.56%   82.38%   -5.19%     
==========================================
  Files          18       20       +2     
  Lines        1641     2254     +613     
  Branches      348      359      +11     
==========================================
+ Hits         1437     1857     +420     
- Misses        149      300     +151     
- Partials       55       97      +42     
Files with missing lines Coverage Δ
line_profiler/line_profiler.py 95.77% <ø> (-3.89%) ⬇️
line_profiler/line_profiler_utils.py 86.95% <83.33%> (-0.55%) ⬇️

... and 11 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 07e3776...6a5db86. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

BUG: ScopingPolicy members improperly typed

2 participants