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

chore(console): remove type errors #5627

Merged
merged 1 commit into from
May 18, 2022

Conversation

branchvincent
Copy link
Member

Removes poetry.console.commands.init from mypy's ignored list

Relates-to: #5017

@@ -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,
Copy link
Member

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?

Copy link
Contributor

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]]]

Copy link
Contributor

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.)

Copy link
Member Author

@branchvincent branchvincent May 17, 2022

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

Copy link
Member

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...

@neersighted neersighted merged commit a00eb5c into python-poetry:master May 18, 2022
@branchvincent branchvincent deleted the mypy/console branch May 18, 2022 02:25
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants