Skip to content

py/path.pyi: fix typing for pyimport#251

Closed
blueyed wants to merge 1 commit into
pytest-dev:masterfrom
blueyed:fix-pyimport
Closed

py/path.pyi: fix typing for pyimport#251
blueyed wants to merge 1 commit into
pytest-dev:masterfrom
blueyed:fix-pyimport

Conversation

@blueyed

@blueyed blueyed commented Jun 30, 2020

Copy link
Copy Markdown
Contributor

This was lost when merging/squashing it into master.

blueyed added a commit to blueyed/pytest that referenced this pull request Jun 30, 2020
Includes fixed typing for pyimport still.
Ref: pytest-dev/py#251

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks

@bluetech

Copy link
Copy Markdown
Member

Sorry for losing it!

But actually I'm not sure we should change it. Consider

mod = path_to_my_module.pyimport()
mod.my_func()

If we type pyimport to return ModuleType, then the second line will be a type error, and the user needs to add # type: Any or cast it or such. Usually in such cases I think it's best to return Any to begin with.

In typeshed for example the __import__ function returns Any: https://github.com/python/typeshed/blob/83e955b52ff0379538441df2cfd0b0e1b4aa5f7e/stdlib/2and3/builtins.pyi#L1737-L1743

@blueyed

blueyed commented Jun 30, 2020

Copy link
Copy Markdown
Contributor Author

Ok, closing then.

@blueyed blueyed closed this Jun 30, 2020
@blueyed blueyed deleted the fix-pyimport branch June 30, 2020 20:19
blueyed added a commit to blueyed/pytest that referenced this pull request Jun 30, 2020
blueyed added a commit to blueyed/pytest that referenced this pull request Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants