Closed henribru closed 2 years ago
[x] I am on the latest (included the beta) Poetry version.
[x] I have searched the issues of this repo and believe that this is not a duplicate.
[x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv
option).
OS version and name: Windows 11
Poetry version: 1.2.0b1
Link of a Gist with the contents of your pyproject.toml file: https://github.com/BrenoJesusFernandes/poetry-stubs-error/blob/master/pyproject.toml
When I add scripts to my pyproject.toml for example:
[tool.poetry.scripts]
some-script = "another_pkg:script:my_function"
I got an error showing that my main stub-only-package is not a package.
Error log: https://github.com/BrenoJesusFernandes/poetry-stubs-error/blob/master/error.log
Is it a bug or am I doing something wrong?
@BrenoJesusFernandes That should probably be its own issue but:
pandas
is inside typings
, but it's actually just directly in the root? pandas
but stub-only packages need to have a -stubs
suffixI had no idea about the second one and works!! But tell me when we build for example the pkg pandas-stubs the stubs are gonna be installed inside the pandas normally?
I had no idea about the second one and works!! But tell me when we build for example the pkg pandas-stubs the stubs are gonna be installed inside the pandas normally?
From my understanding it's installed as an entirely separate package and pip and Poetry don't know that pandas
and pandas-stubs
are related. But your typechecker knows they are so it looks for pandas-stubs
to typecheck pandas
.
Thx for the tip I am new in the world of stubs, I was looking into the pandas stubs project but it was really unclear how things work and I was trying to improve the project by bringing poetry to the battle, do you know why poetry use *-stubs to recognize a stub-only package? Is there a PEP talking about it?
Yeah, should be among the first results if you google "python stub only package"
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
-vvv
option).Issue
PEP561 was recently updated to clarify how to structure stub-only packages for distributions that use namespace packages: https://github.com/python/peps/pull/2083 To summarize, the namespace packages should not have
py.typed
and__init__.pyi
, these should be further down the directory tree in the actual packages. Poetry doesn't support building stub-only packages with this structure, you end up hitting this exception: https://github.com/python-poetry/poetry-core/blob/master/poetry/core/masonry/utils/package_include.py#L83 The reason is that this check is too strict: https://github.com/python-poetry/poetry-core/blob/master/poetry/core/masonry/utils/package_include.py#L49-L54 It expects each file to be either apy.typed
in the root or a.pyi
, which doesn't hold if you have one or morepy.typed
files further down the tree. Seems like simply removing theel.parent.name == self.package
check would fix this issue, so I'd be happy to do a PR for that (though I'm not sure that it's invalid for stub-only packages to include other file types so the check might still be a bit strict).