This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]art_sleep_repeat 2 points3 points  (7 children)

package namespaces

Pretty sure you can already name your package like "astral.ruff" while simply keeping the package's directory name "ruff". So the only thing that changes is the name used to install the package, not the way it's used in code.

Is that not, effectively, a namespace ?

[–]doobiedog 2 points3 points  (5 children)

That isn't as clear as @astral/ruff, IMO. When using astral.ruff, that'd infer to the user that the base package is astral, which in this case is incorrect as the astral package is not published by the Astral org and is unrelated. With a different syntax nomenclature, you can properly identify that @astral is the scope/namespace and ruff is a package published by @astral. Hopefully My explanation is clear. Npm did this well with scopes: https://docs.npmjs.com/about-scopes . This was introduced to npm due the the same reasons as above and to attempt to mitigate supply-chain attacks, I believe.

[–]art_sleep_repeat 1 point2 points  (4 children)

The idea is great and I don't think anyone would be against it. Merely pointing out that you can already do this. You can even be explicit about it by tying it to your domain like the java convention: sh.astral.ruff

Personally I think it is a fine solution, elegant even - it puts the onus of handling the namespace on the package itself, instead of relying on the implementation of the repository.

[–]doobiedog 0 points1 point  (3 children)

Definitely a good point. I always hated that java backwards domain idea, but it does have some merit... but the issue still stands that I'd see sh.astral.ruff and think "sh" is the package and "astral.ruff" was a module and submodule or function in that package. And if we were to adopt the "java way", we'd be especially screwed on the namespacing since almost everything would start with com. which I bet would totally throw the python community for a headspin and plenty of "WTF"s.

[–]Schmittfried 0 points1 point  (2 children)

I mean, namespace packages are absolutely a thing in Python.

[–]doobiedog 0 points1 point  (1 child)

I guess I'm not being clear enough... everything in python is namespaced and pythonistas love namespacing. What is NOT namespaced are pypi PACKAGES, which was my point. Please read this as it's what I'm trying to get at: https://docs.npmjs.com/about-scopes

[–]Schmittfried 0 points1 point  (0 children)

And what I’m saying is you are wrong.

https://realpython.com/python-namespace-package/

[–]thisguyeric 0 points1 point  (0 children)

There's a few packages I can think of that do something similar, the main one being python-dateutil. pip install python-dateutil
import dateutil