Skip to content

Relax requirements about module names to also allow dash characters#164

Merged
abravalheri merged 1 commit into
mainfrom
issue-162
Aug 7, 2024
Merged

Relax requirements about module names to also allow dash characters#164
abravalheri merged 1 commit into
mainfrom
issue-162

Conversation

@abravalheri

Copy link
Copy Markdown
Owner

Closes #162.

See details of the discussion in pypa/setuptools#4316 (comment).

@abravalheri

abravalheri commented Apr 21, 2024

Copy link
Copy Markdown
Owner Author

@henryiii, I don't know what are your thoughts on this.

If you have any (conceptual) concerns, maybe pypa/setuptools#4316 is a good place to discuss?

Comment on lines +292 to +308
def python_module_name_relaxed(value: str) -> bool:
"""Similar to :obj:`python_module_name`, but relaxed to also accept
dash characters (``-``) and cover special cases like ``pip-run``.

It is recommended, however, that beginners avoid dash characters,
as they require advanced knowledge about Python internals.

The following are disallowed:

* names starting/ending in dashes,
* names ending in ``-stubs`` (potentially collide with :obj:`pep561_stub_name`).
"""
if value.startswith("-") or value.endswith("-"):
return False
if value.endswith("-stubs"):
return False # Avoid collision with PEP 561
return python_module_name(value.replace("-", "_"))

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@jaraco would this be enough to support the use case?

I am trying to remain still a bit conservative...

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yes, this seems perfectly reasonable to me. Thanks!

@abravalheri abravalheri marked this pull request as ready for review April 21, 2024 19:34
@henryiii

Copy link
Copy Markdown
Collaborator

Sorry, forgot or missed this. I think this is reasonable.

@abravalheri abravalheri merged commit 43a73b3 into main Aug 7, 2024
@abravalheri abravalheri deleted the issue-162 branch August 7, 2024 13:29
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.

[FR] Relax validation of py-modules

3 participants