-
-
Notifications
You must be signed in to change notification settings - Fork 385
Switch to NG APIs in docs #863
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
Conversation
Did some more converting. A good next step would be to say that type annotations are completely optional, can be replaced by |
I would push back a little on the last part: unchecked type annotations are potentially worse than no type annotations. The number of packages I had to block in mypy.ini is growing every day and even in applications an unchecked type annotation is akin to a comment: it means nothing and can be even confusing. The first part we could probably put into We need to write a chapter on the names tho, but that's something I can do when you're done or even in parallel. Effectively explain the various types and some historic context. Closing #726 in the process. P.S. CI is failing 😇 |
Interesting. We had been using type annotations for about 3 years without ever using Mypy, and I don't mean only in classes; function arguments too. We found it better than nothing, and would use the editor hover popup as a poor man's Mypy :)) But I appreciate your viewpoint too. We are not a library, but an end consumer of them. |
How do I fix |
Co-authored-by: Hynek Schlawack <[email protected]>
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.
- Hashing could use some
attr.s
replacements in copy. - some smaller stuff
- otherwise promising
thanks for doing god's work here Tin!
Co-authored-by: Hynek Schlawack <[email protected]>
for more information, see https://pre-commit.ci
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.
Welcome to the future zone!
Here's what I'm thinking.
Switch
@attr.s
to a bare@define
. This includes also doingfrom attr import define
. I consider@define
to be as cleanest as we can get, and I love it.Remove inheriting from
object
pretty much everywhere. Use modern type annotations whereever possible (solist[int]
instead ofList[int]
). Essentially use all the affordances of modern Python to make the examples as clean as possible.Avoid
= field()/= attr.ib()
whereever possible, while still leaving it in a few places. Again, the syntax with just the type annotation is extremely clean and will probably help sell this to new folks. Preferfield
toattr.ib
.I haven't gone through all the files yet, this is just the start.