-
Notifications
You must be signed in to change notification settings - Fork 46
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
Migrate from attr to attrs #318
Conversation
For Python 3.9, the older style of type hinting is required, I will YOLO-merge this on Wednesday, June 5, unless approved earlier. |
Quality Gate failedFailed conditions |
Not crucial, but does not hurt. This is meant to trigger deepsource analysis
Here's the code health analysis summary for commits Analysis Summary
|
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.
I'm supportive of the change, but recognize that, once again, we are in danger of diverging between QC-Devs packages, which makes things annoying. I'm OK to use iodata
as a trial balloon for these changes, but we need a timeframe to roll (selected or all) changes out across repositories too.
I understand, I'm working my way through a lot of changes these days. I didn't mention this before, but it may be reassuring: most of these changes are based on what is or was outdated in IOData, and what I see in other (popular) Python or other repositories, the tools they use etc. I'm hoping to move to somewhat more long-lived CI solutions. Of course, you never know for sure, but if something is popular or widely endorsed, it seems worth a try. |
This is another part of the renovation items in issue #313.
We used the
attr
library, which has been redesigned into theattrs
library with an improved API. The main improvements inattrs
are clearer names and more convenient default arguments. This is most notable in the changes of:@attr.s(auto_attribs=True, slots=True, on_setattr=[attr.setters.validate, attr.setters.convert])
into
@attrs.define
This update also comes with two strongly related cleanups:
numpy.typing.NDArray
instead ofnumpy.ndarray
. This is a technical detail but useful because class attributes (defined withattrs
) often have type hinting.IOData
object are turned into explicit optional ones, to be more in line with PEP 484. The required changes were at the same lines that were affected by the attrs update.I'm not sure yet if the tests will keep working on Python 3.9 because type hinting has evolved strongly over the last five Python releases. If all works, we may replace a few older type hints by more modern forms:
Otional[X]
->x | None
Union[A, B]
->A | B