Skip to content
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

Enforce plugin name validation to comply with Python package naming conventions #475

Open
Guts opened this issue Oct 9, 2024 · 3 comments
Assignees
Labels
🕔 Size 2 Give me 2 hours and I will have it for you

Comments

@Guts
Copy link

Guts commented Oct 9, 2024

The QGIS plugin manager currently allows the addition of plugins with folder names containing characters that do not comply with Python package naming conventions, such as hyphens (-). Since these plugins are intended to be imported as Python modules within PyQGIS, this can lead to import issues.

According to Python's official guidelines for package naming (PEP 8), module names should use only lowercase letters, digits, and underscores (_). Hyphens and other invalid characters may cause problems when attempting to import the plugin as a Python module.

Proposed solution

Add stricter validation in the QGIS plugin uploader to ensure that plugin folder names comply with Python's package naming rules. Specifically, ensure that:

  • Only lowercase letters, digits, and underscores (_) are allowed.
  • Hyphens (-) and other non-valid characters are disallowed.

Additionally, in the meanwhile, the QGIS plugin's uploader should be handle equivalent names by considering underscores as hyphens, like many Python projects which have to deal with those situations (typer, argparse...): profile-manager = profile_manager

Impact

Enforcing this rule would prevent plugins from being unusable or causing errors during importation in PyQGIS scripts.

For reference:

  • Python's official PEP 8 outlines the naming conventions for packages and modules.
  • The Python Packaging Authority guide provides additional insights into the importance of proper naming conventions for importable packages.
@jfbourdon
Copy link

Enforcing this name validation is a good idea if I prevent potential import errors, but before deploying it, I think that it would be wise to check how many plugins currently available doesn't comply with this convention. There is certaintly quite a lot of plugins containing uppercase letter in there root folder name. If this affect a lot of plugins, a community wide annoucement might be in order to avoid taking developers by surprise.

@Guts
Copy link
Author

Guts commented Oct 16, 2024

I was thinking to apply strict compliance to new published plugins only since it's not possible to rename a plugin's folder.

@Xpirix Xpirix moved this to Todo in Lova Work Planning Oct 18, 2024
@Xpirix Xpirix added the 🕔 Size 2 Give me 2 hours and I will have it for you label Oct 18, 2024
@Xpirix
Copy link
Collaborator

Xpirix commented Nov 14, 2024

Hi @Guts ,

Please find the proposed fix at #486.

Regards.

@Xpirix Xpirix moved this from In Progress to Review in progress in Lova Work Planning Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🕔 Size 2 Give me 2 hours and I will have it for you
Projects
Status: Review in progress
Development

No branches or pull requests

3 participants