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(commands): remove most type errors #5113

Merged
merged 2 commits into from
Jan 27, 2022

Conversation

branchvincent
Copy link
Member

Pull Request Check List

Resolves: #issue-number-here

  • Added tests for changed code.
  • Updated documentation for changed code.

@@ -97,6 +97,7 @@ force-exclude = '''
[tool.mypy]
check_untyped_defs = true
ignore_missing_imports = true
show_error_codes = true
Copy link
Member Author

Choose a reason for hiding this comment

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

this shows error codes, which was useful for our flake8 lint that requires type: ignore[error-code]

@@ -48,11 +48,11 @@ def handle(self) -> None:
self.line_error("<comment>The lock file does not exist. Locking.</comment>")
options = []
if self.io.is_debug():
options.append(("-vvv", None))
options.append("-vvv")
Copy link
Member Author

Choose a reason for hiding this comment

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

Found a bug here 😄

$ rm poetry.lock && poetry export -vv
...
  TypeError

  sequence item 0: expected str instance, tuple found
  at src/poetry/console/commands/export.py:57 in handle
       53│                 options.append(("-vv", None))
       54│             elif self.io.is_verbose():
       55│                 options.append(("-v", None))
       56│ 
    →  57│             self.call("lock", " ".join(options))
       58│ 
       59│         if not locker.is_fresh():
       60│             self.line_error(
       61│                 ""

@@ -86,7 +86,7 @@ def handle(self) -> Optional[int]:
)
return 1

if source.name == name:
if new_source and source.name == name:
Copy link
Member Author

Choose a reason for hiding this comment

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

Without this check, then the below assignment source = new_source maybe have produced source = None

@@ -236,7 +237,7 @@ def handle(self) -> int:
if self.option("lock"):
self._installer.lock()

self._installer.whitelist([r["name"] for r in requirements])
self._installer.whitelist([cast(str, r["name"]) for r in requirements])
Copy link
Member Author

Choose a reason for hiding this comment

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

reached for a cast here as requirements is too loosely typed as Dict[str, Union[str, List[str]]]. planning to tighten that up after removing all ignored files

Copy link
Member

Choose a reason for hiding this comment

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

That's kind of what I expected, sounds good.

src/poetry/console/commands/config.py Outdated Show resolved Hide resolved
src/poetry/console/commands/plugin/add.py Outdated Show resolved Hide resolved
src/poetry/console/commands/remove.py Outdated Show resolved Hide resolved
src/poetry/console/commands/shell.py Outdated Show resolved Hide resolved
src/poetry/console/commands/version.py Outdated Show resolved Hide resolved
@neersighted neersighted merged commit c1c74b9 into python-poetry:master Jan 27, 2022
@branchvincent branchvincent deleted the mypy/commands branch January 27, 2022 19:16
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.

2 participants