-
Notifications
You must be signed in to change notification settings - Fork 57
Numeric submissions aren't allowed by types #151
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
Comments
Could be a bit nicer once wimglenn/advent-of-code-data#151 is addressed.
Could be a bit nicer once wimglenn/advent-of-code-data#151 is addressed.
Hmm, that is a bummer. If you can reproduce this problem in the test suite, PRs fixing it would be welcome. We do already have a pyright action in the workflows, so it's interesting that it doesn't catch this point.
Yes. |
|
There is no reason to depend on pytest, because it's not a runtime dependency. Nothing against uv, but a test |
True, I'm just used to poetry groups/PEP 735 groups/extras being used.
I'm used to Poetry, so I just wasn't expecting a requirements.txt file in a pyproject project; especially given that I thought I'd seen it was a uv project at first. |
Can repro, even in basic mode (I normally use strict, but that lit aocd on fire)
It looks like it's only typechecking the public API, not the tests. (even in basic, it yells and screams about |
@lishaduck #158 does the first part (expose Pinging also @mjpieters who implemented the types for AOCD originally in #131. Martijn, could you please take a look? Is using |
Right, I had fallen into the Number trap here, and should not have used it. See python/mypy#3186 for the long version. I'd change it to |
Oh, yeah, I forgot about this when I got busy with finals. I agree with @mjpieters that |
The mypy issue is closed with a recommendation of using your own |
I thought you had explicitly opt-into protocols, but it looks like they're structural. Good to know.
Declare a protocol that declares A protocol would be ideal, but looking through, perhaps explicitly listing them would work fine?
Use |
Would you agree #158 in its current state is adequate to close this issue? |
Yup! |
Released in v2.1.0. |
Uh oh!
There was an error while loading. Please reload this page.
Pyright gives the following error:
This is ~correct, as
Number
is anABC
, not aProtocol
, despite using duck-typing. Instead, you should usefloat
instead ofNumber
, as, due to Python's coercion, they're indistinguishable on a type level. For more information, there's a lengthy mypy discussion on this at python/mypy#3186.Looking through the source, it looks like there are other valid coercions that should be added as well?
Also, would you be willing to expose
_coerce_val
(Ideally as a function unattached toPuzzle
)? I want to save the coerced value to a text file, to save as a snapshot for tests. Right now I'm using my own basic coercion, but I'd rather know that what I see is what's getting submitted.The text was updated successfully, but these errors were encountered: