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

Add missing type hints - Part 1 #4775

Merged

Conversation

finswimmer
Copy link
Member

@finswimmer finswimmer commented Nov 16, 2021

This is the first part of incremental PR with the goal to force type hints in application code and tests.

This PR adds missing typehints to:

  • application code
  • tests.config
  • test.console

The conftest.py in the tests root folder will be updated whenever needed.

@finswimmer finswimmer force-pushed the improvement/force-type-hints branch 5 times, most recently from 042bae9 to b3b006a Compare November 17, 2021 14:37
@finswimmer finswimmer changed the title Improvement/force type hints Add missing type hints - Part 1 Nov 17, 2021
@finswimmer finswimmer marked this pull request as ready for review November 17, 2021 14:47
@finswimmer finswimmer requested a review from a team November 17, 2021 14:47
Copy link
Member

@neersighted neersighted left a comment

Choose a reason for hiding this comment

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

LGTM!

One question, besides the whitespace nit-picking:
Can/should we turn on Mypy for the affected modules, now that they are fully hinted? As best I can tell, nothing is actually checking that these new hints are correct at the moment.

@@ -64,6 +64,7 @@ pytest-sugar = "^0.9"
httpretty = "^1.0"
zipp = { version = "^3.4", python = "<3.8"}
deepdiff = "^5.0"
typing-extensions = {version = "^4.0.0", python = "<3.8"}
Copy link
Member

Choose a reason for hiding this comment

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

Minor nit, but we are doing spaces around the braces.

(Side note: why doesn't poetry honor with with poetry add?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Because this is how poetry add inserted it, I would prefer leaving it like it is.

@finswimmer
Copy link
Member Author

One question, besides the whitespace nit-picking: Can/should we turn on Mypy for the affected modules, now that they are fully hinted? As best I can tell, nothing is actually checking that these new hints are correct at the moment.

I let mypy inspect these modules. Some of the errors seems to be due to incorrect typings in the application code. This is why I suggest we first fix mypy errors there and have a look at the tests afterwards.

It looks like there are also some tricky errors, e.g.

tests/console/commands/test_show.py:1524: error: "Locker" has no attribute "mock_lock_data"; maybe "_lock_data" or "lock_data"?

This is because the Poetry object gets a TestLocker injected, which inherits from Locker but has some additional methods. Not sure how to teach this to mypy ...

TL;DR: Let us postpone mypy checks for the tests modules.

@neersighted neersighted merged commit f318f6f into python-poetry:master Nov 19, 2021
edvardm pushed a commit to edvardm/poetry that referenced this pull request Nov 24, 2021
* add missing type hints to application code

* add typehints to tests.config, tests.console.commands.debug, tests.console.commands.env

* add typehints to tests.console.commands.plugin

* add typehints to tests.self

* add typehints to tests.console.commands.source

* add typehints to tests.console.commands.about

* add typehints tests.console.commands.add

* add typehints to tests.console.commands.test_cache

* add typehints to tests.console.commands.test_check

* add typehints to tests.console.commands.test_config

* add typehints to tests.console.commands.test_export

* add typehints to tests.console.commands.test_init

* add typehints to tests.console.commands.test_install

* add typehints to tests.console.commands.test_lock

* add typehints to tests.console.commands.test_new

* add typehints to tests.console.commands.test_publish

* add typehints to tests.console.commands.test_remove

* add typehints to tests.console.commands.test_run

* add typehints to tests.console.commands.test_search

* add typehints to tests.console.commands.test_show

* add typehints to tests.console.commands.test_version

* add typehints to tests.console.test_application

* add typehints to tests.console.conftest

* add typehints to tests.console.conftest

* add python version constraint for typing-extension

* fix type hint for http fixture
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.

None yet

2 participants