Skip to content

[DO NOT MERGE!] Fix unicode entrypoint issue #254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

julienmalard
Copy link

@julienmalard julienmalard commented Dec 14, 2024

Fixes: #252

Test for valid unicode Python identifiers (https://peps.python.org/pep-3131/) in entrypoints. Should reproduce #252 .

@julienmalard
Copy link
Author

julienmalard commented Dec 14, 2024

Thanks, done!

I also have a doubt - in the test files, entrypoints are not quoted. However, in a yaml file, the value (attrs) would always be quoted and the key (module) could optionally be quoted as well.
Are the quotes stripped before arriving at the relevant parts of the code?

I also did not understand the extras part of the original regex and so did not reimplement it. Is this fine, or should we add an example of extras the to tests?

@julienmalard julienmalard changed the title Add unicode entrypoint tests Fix unicode entrypoint issue Dec 17, 2024
@julienmalard
Copy link
Author

Fixes #252

@Secrus
Copy link
Member

Secrus commented Dec 29, 2024

I also did not understand the extras part of the original regex and so did not reimplement it. Is this fine, or should we add an example of extras the to tests?

It's a legacy distutils/setuptools thing, that allowed for a conditional installation of the entrypoint based on the chosen extra. It's not a standard anymore, but we should keep it working and the new implementation should consider it a viable (although ignored) part of an entrypoint spec.

@Secrus
Copy link
Member

Secrus commented Feb 7, 2025

@julienmalard do you plan on working on this PR?

@julienmalard
Copy link
Author

Thanks for the reminder, @Secrus ! I've added the code to parse and ignore extras, as well as a relevant test. Please let me know if this looks good.

@julienmalard
Copy link
Author

Hello @Secrus
Did you have a chance to check these changes?

@Secrus
Copy link
Member

Secrus commented Apr 8, 2025

@julienmalard I have consulted with @pradyunsg, and we decided that while technically correct, we shouldn't introduce that change while other parts of the ecosystem (like importlib.metadata) don't follow the same rules. If this is important to you, please start a discussion on https://discuss.python.org/ to fix the issue across the whole ecosystem. I will keep the PR open until the consensus is reached.

@Secrus Secrus changed the title Fix unicode entrypoint issue [DO NOT MERGE!] Fix unicode entrypoint issue Apr 8, 2025
@julienmalard
Copy link
Author

Thanks @Secrus for the update. For reference, this works with Poetry.
I've created a discussion as suggested here: https://discuss.python.org/t/unicode-identifiers-as-python-entrypoints/87540
Do you have any details on which part of importlib.metadata isn't PEP3131-compliant? I'd be happy to start a PR there as well.

assert attrs is not None
assert isinstance(attrs, str)
assert len(attrs), "Attributes are empty"
assert attrs.isidentifier(), f"{attrs} is not a valid identifier"
Copy link
Member

Choose a reason for hiding this comment

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

We should raise proper exceptions, instead of assertion errors, for issues related to the user provided inputs. (the older asserts were there to guide type checkers).

Copy link
Author

Choose a reason for hiding this comment

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

I can do that @pradyunsg
By the way, is the discussion here satisfactory? In brief, they have confirmed that our proposed change here is standards-compliant (more so than the original one) and note that other tools in the ecosystem may require a similar patch as well for unicode to fully function.

Copy link
Author

Choose a reason for hiding this comment

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

We should raise proper exceptions, instead of assertion errors, for issues related to the user provided inputs. (the older asserts were there to guide type checkers).

Is there a particular Exception class you would recommend?

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.

Error in unicode entry scripts
4 participants