-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: add @final
to contents, types, and forms
#2033
Conversation
Codecov Report
Additional details and impacted files
|
A warning from PyLint (they easily get buried):
Is there a way to import it as backports for Python versions as early as 3.7? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right: the Content
, Form
, and Type
subclasses should not be subclassed; they're final.
So are ak.types.ArrayType
, ak.record.Record
, and the ak.index.Index
subclasses (e.g. ak.index.Index64
). These are not subclasses of the above, but are closely related.
I suppose you can't annotate Content
, Form
, and Type
(the superclasses) to say that they can't have subclasses beyond those that are defined in our codebase. (I think Scala has a way to say that: they have a lot of module-level/namespace-level type qualifiers.)
Also, this would only prevent people from defining subclasses and then type-checking them, right? We're not preventing people from hacking things as a test—just formally declaring something as "okay for production," right?
This is done, it just needs a fix for mypy on older Python versions. I think the issue is how we import
Unfortunately not, but I think we'll be OK at least with constraining the immediate subclasses.
Right, this is not runtime-enforced at all. |
6e47ba3
to
46d477f
Compare
This type hint makes it clear (and, in future, enforces) that contents, types, and forms are all final non-inheritable types.