Skip to content

Type completeness improvement (timeouts, CancelScope, and more)#2671

Merged
jakkdl merged 12 commits into
python-trio:masterfrom
jakkdl:typing_improvements
Jul 3, 2023
Merged

Type completeness improvement (timeouts, CancelScope, and more)#2671
jakkdl merged 12 commits into
python-trio:masterfrom
jakkdl:typing_improvements

Conversation

@jakkdl

@jakkdl jakkdl commented Jun 26, 2023

Copy link
Copy Markdown
Member

Just going down the list of untyped symbols, don't think there's much anything tricky. Will run trio-typing/stubtest against the changes

@codecov

codecov Bot commented Jun 26, 2023

Copy link
Copy Markdown

Codecov Report

Merging #2671 (2773e54) into master (9457f3c) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2671   +/-   ##
=======================================
  Coverage   98.84%   98.84%           
=======================================
  Files         113      113           
  Lines       16477    16484    +7     
  Branches     3003     3003           
=======================================
+ Hits        16286    16293    +7     
  Misses        134      134           
  Partials       57       57           
Impacted Files Coverage Δ
trio/_core/_exceptions.py 100.00% <100.00%> (ø)
trio/_core/_run.py 99.24% <100.00%> (+<0.01%) ⬆️
trio/_timeouts.py 100.00% <100.00%> (ø)
trio/_util.py 100.00% <100.00%> (ø)

@jakkdl

jakkdl commented Jun 26, 2023

Copy link
Copy Markdown
Member Author

Didn't see anything of interest running stubtest - although trio-stubs are plenty out of date and messy anyway so idk if it says much.

@A5rocks what is the ideal size for pure typing PRs like this, in your opinion? I could easily continue and chug through tons of symbols, but don't want to saddle you with huge code reviews.

"trio._sync.Event.is_set",
"trio._sync.Event.wait",
"trio._sync.Event.statistics",
"trio._sync.CapacityLimiter",

@jakkdl jakkdl Jun 26, 2023

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Most/all of these random classes being type complete is due to Final.__new__ and NoPublicConstructor.__call__ getting typed.

@A5rocks

A5rocks commented Jun 26, 2023

Copy link
Copy Markdown
Contributor

I don't really have a preferred size given I'm not too used to typing PRs. I'd kinda like smaller ones, I think. Maybe an exported function and everything it depends on or about that much length in diffs? Reread this, and I don't know. Up to you, really.

(Basically I don't really think I care about length, just about having the context to check types!)

@jakkdl

jakkdl commented Jun 26, 2023

Copy link
Copy Markdown
Member Author

huh, what's going on with codecov? Maybe something about run getting canceled?

@A5rocks A5rocks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think most of the changes aren't objectionable, but a couple small comments.

Comment thread trio/_timeouts.py Outdated
Comment thread trio/_util.py Outdated
Comment thread trio/_util.py Outdated
Comment thread trio/_util.py
@@ -1,4 +1,5 @@
# Little utilities we use internally
from __future__ import annotations

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we preemptively stick this at the top of all files so that these kinds of change is already done?

@A5rocks A5rocks Jun 26, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually IDK how I feel about using the cooler syntax early: we could use typing.List etc. and already-mentioned pyupgrade will drop that for newer syntax the moment we drop 3.8.

On the other hand it's more readable and more understandable. Though I guess List[int] vs list[int] (using from typing import ...) isn't too big a difference.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The biggest downside to using typing.List is the additional overhead in import management - which is fully manual given our current lack of isort. This can be quite frustrating IME.

idc much whether to preemptively adding it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

fucking github. anyway there's never a reason not to use from __future__ import annotations so you might as well just use 3.11+ typing syntax always.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

python-trio/flake8-async#78 (review)
Instagram/LibCST#870
There's some scenarios where it matters, but I think we're fine.

@A5rocks

A5rocks commented Jun 26, 2023

Copy link
Copy Markdown
Contributor

huh, what's going on with codecov? Maybe something about run getting canceled?

It looks like codecov broke something: https://github.com/python-trio/trio/actions/runs/5378612122/jobs/9758650074?pr=2671#step:6:39

I've just rerun the jobs in case that fixes it.

Edit: I've investigated and found: codecov/feedback#126.

@jakkdl jakkdl force-pushed the typing_improvements branch from 421f46f to 2fd06b9 Compare June 26, 2023 16:21
@jakkdl jakkdl requested a review from A5rocks June 26, 2023 16:27
Comment thread trio/_core/_run.py
Comment thread trio/_timeouts.py Outdated
Comment thread trio/_timeouts.py
Comment thread trio/_timeouts.py Outdated
@jakkdl jakkdl force-pushed the typing_improvements branch from 56238aa to 5195433 Compare July 1, 2023 10:47
@Fuyukai

Fuyukai commented Jul 1, 2023

Copy link
Copy Markdown
Member

That's my comments addressed fine.

@jakkdl jakkdl merged commit 4816f0e into python-trio:master Jul 3, 2023
@jakkdl jakkdl deleted the typing_improvements branch July 3, 2023 12:01
@A5rocks A5rocks added the typing Adding static types to trio's interface label Jul 18, 2023
@Zac-HD Zac-HD mentioned this pull request Jul 21, 2023
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

typing Adding static types to trio's interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants