Skip to content

add a deprecation decorator#5

Merged
ilia-kats merged 5 commits intomainfrom
deprecation_decorator
Apr 10, 2026
Merged

add a deprecation decorator#5
ilia-kats merged 5 commits intomainfrom
deprecation_decorator

Conversation

@ilia-kats
Copy link
Copy Markdown
Collaborator

As per the discussion in scverse/mudata#131.

Apparently it's not really possible to add arguments to the __init__ of str subclasses, so I'm using a dataclass instead.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.43%. Comparing base (2a0be55) to head (c772029).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main       #5      +/-   ##
==========================================
+ Coverage   96.38%   97.43%   +1.05%     
==========================================
  Files           2        3       +1     
  Lines          83      117      +34     
==========================================
+ Hits           80      114      +34     
  Misses          3        3              
Files with missing lines Coverage Δ
src/scverse_misc/__init__.py 100.00% <100.00%> (ø)
src/scverse_misc/_deprecated.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ilia-kats ilia-kats force-pushed the deprecation_decorator branch from 2691253 to 870748a Compare April 9, 2026 11:44
@ilia-kats ilia-kats force-pushed the deprecation_decorator branch from 870748a to c1323f8 Compare April 9, 2026 11:46
Copy link
Copy Markdown
Member

@Zethson Zethson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ name = "Ilia Kats" },
]
requires-python = ">=3.11"
requires-python = ">=3.10"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for that. We're following spec-0 so we're more or less already at Python 3.12+

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but mudata 0.3.x is still on 3.10+. I'll bump it for 0.4, but for now I'd prefer to keep it.

Copy link
Copy Markdown
Member

@Zethson Zethson Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think MuData received so many changes, it's fine to just release 0.4.0 next. The current MuData main branch can already be 3.12+.

But this is not a big problem (unless you have to adapt it again - see Phil's Generics suggestion) so whatever you think makes sense.

Thanks!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything so far has been backwards compatible, so my plan currently is to release 0.3.4 after the deprecation PR has been merged, this will be the last 0.3.x release.

Copy link
Copy Markdown
Member

@flying-sheep flying-sheep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently it's not really possible to add arguments to the __init__ of str subclasses, so I'm using a dataclass instead.

if it’s not a str subclass, it won’t typecheck. __new__ works!

class Test(str):
    def __new__(cls, version, msg):
        obj = str.__new__(cls, f"{msg} (since {v})")
        obj.version = Version(version)
        return obj

@ilia-kats
Copy link
Copy Markdown
Collaborator Author

if it’s not a str subclass, it won’t typecheck. __new__ works!

Is it typechecked at all? I don't see deprecated in the corresponding typeshed file

@flying-sheep
Copy link
Copy Markdown
Member

flying-sheep commented Apr 9, 2026

Everything in the stdlib is typechecked! I guess you have the wrong file.

@ilia-kats
Copy link
Copy Markdown
Collaborator Author

Ah, found it. However, if I'm reading this right, your version also won't typecheck, since it wants a LiteralString for message.

@ilia-kats
Copy link
Copy Markdown
Collaborator Author

@flying-sheep Exactly, it's complaining about Deprecation not being LiteralString: https://play.ty.dev/322b2994-2dbe-4e47-917f-1666a32fe432

@flying-sheep
Copy link
Copy Markdown
Member

flying-sheep commented Apr 9, 2026

no problem, just do def __new__(...) -> LiteralString!

Also no from typing import TypeVar, please, just Python 3.12 generics syntax.

@ilia-kats
Copy link
Copy Markdown
Collaborator Author

no problem, just do def __new__(...) -> LiteralString!

Thanks, done.

Also no from typing import TypeVar, please, just Python 3.12 generics syntax.

As mentioned above, mudata 0.3.x is still Python 3.10+ and I'd like to avoid bumping the mudata requirements in the 0.3 series. I'll bump it for 0.4 and then also make a new scverse-misc version that is 3.12+.

@ilia-kats ilia-kats requested a review from flying-sheep April 9, 2026 15:06
@ilia-kats ilia-kats force-pushed the deprecation_decorator branch from bec2a6a to 794ef34 Compare April 9, 2026 15:07
Copy link
Copy Markdown
Member

@flying-sheep flying-sheep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make the minimum version test job also run on 3.10 when you extend the support window, and simplify a bit using inspect otherwise this looks good!

- run tests on Python 3.10
- simplify warning message generation
- LiteralString type hints
@ilia-kats ilia-kats merged commit fa6d6f2 into main Apr 10, 2026
9 checks passed
@ilia-kats ilia-kats deleted the deprecation_decorator branch April 10, 2026 15:05
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.

3 participants