(original) (raw)
On Sun, Nov 12, 2017 at 8:07 PM, Nathaniel Smith <njs@pobox.com> wrote:
On Sun, Nov 12, 2017 at 11:21 AM, Ethan Smith <ethan@ethanhs.me> wrote:
\>
\>
\> On Sun, Nov 12, 2017 at 9:53 AM, Jelle Zijlstra <jelle.zijlstra@gmail.com>
\> wrote:
\>>
\>> 2017-11-12 3:40 GMT-08:00 Ethan Smith <ethan@ethanhs.me>:
>>> The name of the stub
\>>> package
\>>> MUST follow the scheme \`\`pkg\_stubs\`\` for type stubs for the package named
\>>> \`\`pkg\`\`. The normal resolution order of checking \`\`\*.pyi\`\` before
\>>> \`\`\*.py\`\`
\>>> will be maintained.
\>>
\>> This is very minor, but what do you think of using "pkg-stubs" instead of
\>> "pkg\_stubs" (using a hyphen rather than an underscore)? This would make the
\>> name illegal to import as a normal Python package, which makes it clear that
\>> it's not a normal package. Also, there could be real packages named
\>> "\_stubs".
\>
\> I suppose this makes sense. I checked PyPI and as of a few weeks ago there
\> were no packages with the name pattern, but I like the idea of making it
\> explicitly non-runtime importable. I cannot think of any reason not to do
\> it, and the avoidance of confusion about the package being importable is a
\> benefit. I will make the change with my next round of edits.
PyPI doesn't distinguish between the names 'foo-stubs' and 'foo\_stubs'
\-- they get normalized together. So even if you use 'foo-stubs' as the
directory name on sys.path to avoid collisions at import time, it
still won't allow someone to distribute a separate 'foo\_stubs' package
on PyPI.
If you do go with a fixed naming convention like this, the PEP should
probably also instruct the PyPI maintainers that whoever owns 'foo'
automatically has the right to control the name 'foo-stubs' as well.
Or maybe some tweak to PEP 541 is needed.
As I understand it however, the distribution name need not map to to the
package name in any way. So regardless of if foo-stubs is seen as
foo\_stubs, I could name the distribution Albatross if I wished, and
install the foo-stubs package into site/dist-packages, and it would work. Also I'm not sure if the PyPI change would require an edict from a PEP, but if so, I wouldn't be opposed to the idea, I think it would be nice to default the stub packages to the owners of the normal packages (people should, to my understanding, be able to make alternate distributions without hassle).
Ethan
\-n
\--
Nathaniel J. Smith -- https://vorpus.org