-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
chore(console): remove type errors #5627
Conversation
0e1c0fa
to
f53052e
Compare
@@ -50,8 +51,8 @@ def __init__( | |||
author: str | None = None, | |||
license: str | None = None, | |||
python: str = "*", | |||
dependencies: dict[str, str] | None = None, | |||
dev_dependencies: dict[str, str] | None = None, | |||
dependencies: dict[str, str | Mapping[str, Any]] | None = None, |
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.
why do you use dict[]
here and Dict[]
in init.py
Requirements
type declaration? shouldn't this be in the same notation?
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.
mypy seems unhappy with the lower-case version when defining a type alias, we have a couple of similar examples here and in poetry-core eg
DependencySpec = Dict[str, Union[str, bool, Dict[str, Union[str, bool]], List[str]]] |
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.
(wow, what a monster that is...! I'd have settled for dict[str, Any]
here.)
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.
The difference here is because a type alias is executed at runtime:
name = Dict[str, str]
name = dict[str, str] # syntax error for <3.10
whereas a type hint isn't, since we've opted in to PEP 563 (with from __future__ import annotations
):
name: dict[str, str]
name: 'dict[str, str]' # equivalent representation
I actually didn't handle this on my first push, so you can see the syntax error it caused here
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.
Ah, that makes sense and I technically knew that -- but forgot it after not looking at this for a couple months...
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Removes
poetry.console.commands.init
from mypy's ignored listRelates-to: #5017