mirror of
https://opendev.org/openstack/python-keystoneclient.git
synced 2026-01-17 07:20:28 +00:00
Add hacking rules to prevent eventlet usage
Introduce flake8 hacking checks to prevent future eventlet usage in keystoneclient. This helps maintain code quality and prevents regression to deprecated eventlet patterns after the recent eventlet removal. - Add K001 check for eventlet imports - Add K002 check for eventlet usage patterns in code - Register checks as flake8 extensions in setup.cfg - Skip comments and docstrings to avoid false positives - Add hacking to docs requirements to fix autodoc import The checks will catch patterns like: - import eventlet / from eventlet import ... - eventlet.*, green.*, patcher.*, already_patched references Generated-By: Claude Code Change-Id: I26350578fa58f8f2b16821aeeeafbd58fac4b168 Signed-off-by: Hervé Beraud <hberaud@redhat.com>
This commit is contained in:
parent
ee58ef4d00
commit
67d6c71b8d
4 changed files with 76 additions and 0 deletions
|
|
@ -5,3 +5,4 @@ sphinxcontrib-apidoc>=0.2.0 # BSD
|
|||
reno>=3.1.0 # Apache-2.0
|
||||
lxml>=3.4.1 # BSD
|
||||
fixtures>=3.0.0 # Apache-2.0/BSD
|
||||
hacking>=6.1.0,<6.2.0 # Apache-2.0
|
||||
|
|
|
|||
13
keystoneclient/hacking/__init__.py
Normal file
13
keystoneclient/hacking/__init__.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""keystoneclient hacking checks module."""
|
||||
58
keystoneclient/hacking/checks.py
Normal file
58
keystoneclient/hacking/checks.py
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""keystoneclient's pep8 extensions.
|
||||
|
||||
In order to make the review process faster and easier for core devs we are
|
||||
adding some keystoneclient specific pep8 checks. This will catch common
|
||||
errors so that core devs don't have to.
|
||||
|
||||
"""
|
||||
|
||||
import re
|
||||
|
||||
from hacking import core
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
def check_no_eventlet_imports(logical_line):
|
||||
"""Check for eventlet imports.
|
||||
|
||||
K001: eventlet usage is deprecated in keystoneclient.
|
||||
"""
|
||||
if re.match(r'^\s*(import\s+eventlet|from\s+eventlet)', logical_line):
|
||||
yield (0, "K001 eventlet usage is deprecated in keystoneclient")
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
def check_no_eventlet_references(logical_line):
|
||||
"""Check for eventlet references in code.
|
||||
|
||||
K002: eventlet usage is deprecated in keystoneclient.
|
||||
"""
|
||||
# Skip comments and docstrings
|
||||
if (logical_line.strip().startswith('#') or
|
||||
'"""' in logical_line or "'''" in logical_line):
|
||||
return
|
||||
|
||||
# Check for eventlet usage patterns
|
||||
eventlet_patterns = [
|
||||
r'eventlet\.',
|
||||
r'green\.',
|
||||
r'patcher\.',
|
||||
r'\balready_patched\b',
|
||||
]
|
||||
|
||||
for pattern in eventlet_patterns:
|
||||
if re.search(pattern, logical_line):
|
||||
yield (0, "K002 eventlet usage is deprecated in keystoneclient")
|
||||
break # Only report one error per line
|
||||
|
|
@ -36,3 +36,7 @@ keystoneclient.auth.plugin =
|
|||
v3unscopedsaml = keystoneclient.contrib.auth.v3.saml2:Saml2UnscopedToken
|
||||
v3scopedsaml = keystoneclient.contrib.auth.v3.saml2:Saml2ScopedToken
|
||||
v3unscopedadfs = keystoneclient.contrib.auth.v3.saml2:ADFSUnscopedToken
|
||||
|
||||
flake8.extension =
|
||||
K001 = keystoneclient.hacking.checks:check_no_eventlet_imports
|
||||
K002 = keystoneclient.hacking.checks:check_no_eventlet_references
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue