Skip to content
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

Tweak stubs for better VS Code import #1234

Merged
merged 6 commits into from
Feb 4, 2024
Merged

Tweak stubs for better VS Code import #1234

merged 6 commits into from
Feb 4, 2024

Conversation

Tinche
Copy link
Member

@Tinche Tinche commented Feb 2, 2024

I moved the definitions of define, mutable, frozen and field to attrs, and made attr import them.

Screenshot 2024-02-03 at 00 24 34

Then I modernized the stubs since I couldn't help myself. We can use modern typing stuff in stubs.

This was motivated by microsoft/pylance-release#5388.

@Tinche Tinche requested a review from hynek February 2, 2024 23:49
@Tinche
Copy link
Member Author

Tinche commented Feb 2, 2024

After this release goes out, let's move the others too (Factory, has, fields, AttrsInstance, etc).

@hynek
Copy link
Member

hynek commented Feb 3, 2024

Are you positive the new syntax doesn’t break something somewhere? I’ve got this vague memory of trying it myself and having to abort. We also kinda stopped running Mypy on 3.7. 🤔

changelog.d/1234.change.md Outdated Show resolved Hide resolved
@Tinche
Copy link
Member Author

Tinche commented Feb 3, 2024

My main work codebase is 3.8 and Mypy 1.8.0, no problems here. Best I can do :( Can you run it over your stuff?

PEP 604 (new union syntax) is from 2019 so typecheckers have had some time to catch up.

sOmEoNe forgot how to write changelogs eh ಠ_ಠ

Are we writing snippets for devs to scan through or novels for when you're on the toilet? 🤔

@hynek
Copy link
Member

hynek commented Feb 3, 2024

My main work codebase is 3.8 and Mypy 1.8.0, no problems here.

Thoughts and prayers!

Best I can do :( Can you run it over your stuff?

I’m all 3.12. 😇

PEP 604 (new union syntax) is from 2019 so typecheckers have had some time to catch up.

Right, we’re benefiting once again from our external typing stubs, aren’t we?

sOmEoNe forgot how to write changelogs eh ಠ_ಠ

Are we writing snippets for devs to scan through or novels for when you're on the toilet? 🤔

Yes!

@Tinche
Copy link
Member Author

Tinche commented Feb 3, 2024

Right, we’re benefiting once again from our external typing stubs, aren’t we?

Yeah. We would also benefit if we were using from __future__ import annotations, although our annotations wouldn't be introspectable at runtime. (But stubs aren't introspectable either, so...)

@hynek
Copy link
Member

hynek commented Feb 4, 2024

There's a few cases where that doesn't work as well tho, because sometimes types aren't used just as annotations. Stuff like T = X | list[Y] -- so that's an upside of pyi I guess.

@hynek hynek added this pull request to the merge queue Feb 4, 2024
Merged via the queue into main with commit 06dc279 Feb 4, 2024
20 checks passed
@hynek hynek deleted the tin/modernize-stubs branch February 4, 2024 06:03
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