From 59ec11d18733c2b0839c2ef1e722c816df9fcc3d Mon Sep 17 00:00:00 2001 From: Lova Andriarimalala <43842786+Xpirix@users.noreply.github.com> Date: Fri, 15 Nov 2024 14:14:09 +0300 Subject: [PATCH] Use str.isidentifier instead of regex --- qgis-app/plugins/validator.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/qgis-app/plugins/validator.py b/qgis-app/plugins/validator.py index a7e9c7b..639c03a 100644 --- a/qgis-app/plugins/validator.py +++ b/qgis-app/plugins/validator.py @@ -245,11 +245,12 @@ def validator(package, is_new: bool = False): ) ) # Check if package_name is PEP 8 compliant - if is_new and not re.match(r"^[a-z_][a-z0-9_]*$", package_name): + if is_new and not package_name.isidentifier(): raise ValidationError( _( "The name of the top level directory inside the zip package must be PEP 8 compliant: " - "lowercase with words separated by underscores, and must start with a letter or underscore." + "a valid Python identifier, which means it must start with a letter or underscore, " + "and can only contain letters, digits, and underscores." ) )