-
Notifications
You must be signed in to change notification settings - Fork 59
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
Replace pkg_resources #232
Conversation
odkhang
commented
Jul 11, 2024
This reverts commit 30d8dc5.
src/pretix/base/plugins.py
Outdated
@@ -6,6 +6,7 @@ | |||
from django.apps import AppConfig, apps | |||
from django.conf import settings | |||
from django.core.exceptions import ImproperlyConfigured | |||
import importlib.metadata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this import line to the top. Separate import lines to 3 groups as PEP8
recommendation.
src/pretix/base/plugins.py
Outdated
package_name, _, required_version = requirement.partition("==") | ||
installed_version = importlib.metadata.version(package_name) | ||
if installed_version != required_version: | ||
print("Incompatible plugins found!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use print
. Use logger instead.
Hi @hongquan , Thank you very much! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't embed data to log message like this:
logger.error(f"Plugin {self.name} requires you to have {package_name}=={required_version}")
Because when we don't want to emit the log message (by adjusting log level), the variables are still evaluated to build the string.
Please pass the variables as parameters, like this:
logger.error('Plugin %s requires you to have %s==%s', self.name, package_name, required_version)
By this, the variables are only evaluated when the log level matches and the logging system is about to emit messages.
Hi @hongquan, |
* Replace pkg_resources with import importlib_metadata
* Replace pkg_resources with import importlib_metadata
* Replace pkg_resources with import importlib_metadata
* Replace pkg_resources with import importlib_metadata
* Replace pkg_resources with import importlib_metadata
* Replace pkg_resources with import importlib_metadata