Skip to content

Refactor scale offset into dedicated helper functions. - #8449

Merged
Jens Hedegaard Nielsen (jenshnielsen) merged 3 commits into
microsoft:mainfrom
jenshnielsen:cleanup_scale_offset
Aug 27, 2026
Merged

Refactor scale offset into dedicated helper functions.#8449
Jens Hedegaard Nielsen (jenshnielsen) merged 3 commits into
microsoft:mainfrom
jenshnielsen:cleanup_scale_offset

Conversation

@jenshnielsen

@jenshnielsen Jens Hedegaard Nielsen (jenshnielsen) commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

The scale and offset conversions assume a numeric data type and rely on catching TypeError, which does not fit the generic parameter data type. They were expressed inline, so the working variable was repeatedly narrowed to whatever the last branch assigned, and each step needed a suppression.

Move them into four module level helpers that take and return Any. This keeps the arithmetic out of the generic class, deduplicates the iterable and scalar branches, and drops the suppressions in this file from 15 to 3.

Also stop routing issuperset through contains, which ty cannot resolve on Self when the class type parameter has a bound. Removed since this issue is fixed in ty as of 0.74.0

lifted from #8441

The scale and offset conversions assume a numeric data type and rely on
catching TypeError, which does not fit the generic parameter data type.
They were expressed inline, so the working variable was repeatedly
narrowed to whatever the last branch assigned, and each step needed a
suppression.

Move them into four module level helpers that take and return Any. This
keeps the arithmetic out of the generic class, deduplicates the iterable
and scalar branches, and drops the suppressions in this file from 15 to
3.

Also stop routing issuperset through __contains__, which ty cannot
resolve on Self when the class type parameter has a bound.
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.14%. Comparing base (f12be6b) to head (8f0ab85).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8449      +/-   ##
==========================================
+ Coverage   71.12%   71.14%   +0.01%     
==========================================
  Files         305      305              
  Lines       31952    31960       +8     
==========================================
+ Hits        22725    22737      +12     
+ Misses       9227     9223       -4     

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

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

Cover the iterable branches of the set path helpers, the TypeError
fallbacks and re-raise of the get path helpers, and add direct unit
tests for the four module level helpers. Also add the missing tests
for ParameterSet.issubset/issuperset.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e8c5964a-6418-4d35-b69c-bb44dd727a3c
@jenshnielsen
Jens Hedegaard Nielsen (jenshnielsen) removed this pull request from the merge queue due to a manual request Aug 27, 2026
Merged via the queue into microsoft:main with commit 3f2f690 Aug 27, 2026
17 checks passed
@jenshnielsen
Jens Hedegaard Nielsen (jenshnielsen) deleted the cleanup_scale_offset branch August 27, 2026 08:39
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.

2 participants