diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3ab0cee8a7..10d7331e5d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,7 +30,7 @@ repos: exclude: 'nova/virt/ironic/ironic_states.py' - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.5.5 + rev: v1.5.6 hooks: - id: remove-tabs exclude: '.*\.(svg)$' @@ -46,7 +46,7 @@ repos: # fixing an issue changes the code and that should # not happen in ci. - repo: https://opendev.org/openstack/hacking - rev: 7.0.0 + rev: 8.0.0 hooks: - id: hacking additional_dependencies: [] @@ -59,7 +59,7 @@ repos: args: ['--ignore-words=doc/dictionary.txt'] - repo: https://github.com/sphinx-contrib/sphinx-lint - rev: v1.0.1 + rev: v1.0.2 hooks: - id: sphinx-lint args: [--enable=default-role] diff --git a/nova/api/validation/extra_specs/validators.py b/nova/api/validation/extra_specs/validators.py index 361d35b108..b384e8604a 100644 --- a/nova/api/validation/extra_specs/validators.py +++ b/nova/api/validation/extra_specs/validators.py @@ -64,8 +64,6 @@ def validate(name: str, value: str): def load_validators(): - global VALIDATORS - def _report_load_failure(mgr, ep, err): LOG.warning(u'Failed to load %s: %s', ep.module_name, err) diff --git a/nova/api/validation/parameter_types.py b/nova/api/validation/parameter_types.py index 29253aa583..9459014178 100644 --- a/nova/api/validation/parameter_types.py +++ b/nova/api/validation/parameter_types.py @@ -30,7 +30,6 @@ _REGEX_RANGE_CACHE = {} def memorize(func): @functools.wraps(func) def memorizer(*args, **kwargs): - global _REGEX_RANGE_CACHE key = "%s:%s:%s" % (func.__name__, hash(str(args)), hash(str(kwargs))) value = _REGEX_RANGE_CACHE.get(key) if value is None: diff --git a/nova/context.py b/nova/context.py index ebb5d2f2be..cf8dd78668 100644 --- a/nova/context.py +++ b/nova/context.py @@ -335,7 +335,6 @@ def set_target_cell(context, cell_mapping): :param context: The RequestContext to add connection information :param cell_mapping: An objects.CellMapping object or None """ - global CELL_CACHE if cell_mapping is not None: # avoid circular import from nova.db.main import api as db diff --git a/nova/privsep/fs.py b/nova/privsep/fs.py index 0ba25ca852..c99f4d0c3a 100644 --- a/nova/privsep/fs.py +++ b/nova/privsep/fs.py @@ -261,7 +261,6 @@ _DEFAULT_FS_BY_OSTYPE = {'linux': FS_FORMAT_EXT4, def load_mkfs_command(os_type, command): - global _MKFS_COMMAND global _DEFAULT_MKFS_COMMAND _MKFS_COMMAND[os_type] = command @@ -270,8 +269,6 @@ def load_mkfs_command(os_type, command): def get_fs_type_for_os_type(os_type): - global _MKFS_COMMAND - return os_type if _MKFS_COMMAND.get(os_type) else 'default' @@ -289,9 +286,6 @@ def _get_hash_str(base_str): def get_file_extension_for_os_type(os_type, default_ephemeral_format, specified_fs=None): - global _MKFS_COMMAND - global _DEFAULT_MKFS_COMMAND - mkfs_command = _MKFS_COMMAND.get(os_type, _DEFAULT_MKFS_COMMAND) if mkfs_command: extension = mkfs_command @@ -352,9 +346,6 @@ def configurable_mkfs(os_type, fs_label, target, run_as_root, # os type. If user has not provided any configuration, format type will # be used according to a default_ephemeral_format configuration or a # system default. - global _MKFS_COMMAND - global _DEFAULT_MKFS_COMMAND - mkfs_command = (_MKFS_COMMAND.get(os_type, _DEFAULT_MKFS_COMMAND) or '') % {'fs_label': fs_label, 'target': target} if mkfs_command: diff --git a/nova/quota.py b/nova/quota.py index 250fd12994..24b74749d0 100644 --- a/nova/quota.py +++ b/nova/quota.py @@ -1376,7 +1376,6 @@ def _instances_cores_ram_count(context, project_id, user_id=None): 'cores': , 'ram': }} """ - global UID_QFD_POPULATED_CACHE_BY_PROJECT if CONF.quota.count_usage_from_placement: # If a project has all user_id and queued_for_delete data populated, # cache the result to avoid needless database checking in the future. diff --git a/nova/tests/fixtures/nova.py b/nova/tests/fixtures/nova.py index 615b76167e..0d9d68229e 100644 --- a/nova/tests/fixtures/nova.py +++ b/nova/tests/fixtures/nova.py @@ -420,7 +420,6 @@ class CellDatabases(fixtures.Fixture): def _cache_schema(self, connection_str): # NOTE(melwitt): See the regular Database fixture for why # we do this. - global DB_SCHEMA if not DB_SCHEMA[('main', None)]: ctxt_mgr = self._ctxt_mgrs[connection_str] engine = ctxt_mgr.writer.get_engine() @@ -706,7 +705,6 @@ class Database(fixtures.Fixture): self.addCleanup(self.cleanup) def _apply_schema(self): - global DB_SCHEMA if not DB_SCHEMA[(self.database, self.version)]: # apply and cache schema engine = self.get_engine() diff --git a/nova/tests/unit/compute/test_compute.py b/nova/tests/unit/compute/test_compute.py index 0eb7be87aa..9e49034455 100644 --- a/nova/tests/unit/compute/test_compute.py +++ b/nova/tests/unit/compute/test_compute.py @@ -7399,9 +7399,6 @@ class ComputeTestCase(BaseTestCase, raised_exc = None def fake_db_fault_create(ctxt, values): - global exc_info - global raised_exc - self.assertIn('raise messaging.RemoteError', values['details']) self.assertIn('Remote error: test My Test Message\nNone.', values['details']) diff --git a/nova/tests/unit/fake_network.py b/nova/tests/unit/fake_network.py index eb3f74da06..8246b6e9e2 100644 --- a/nova/tests/unit/fake_network.py +++ b/nova/tests/unit/fake_network.py @@ -154,11 +154,12 @@ def set_stub_network_methods(test): def unset_stub_network_methods(test): - global _real_functions - if _real_functions: - for name in _real_functions: - test.stub_out('nova.compute.manager.ComputeManager.' + name, - _real_functions[name]) + if not _real_functions: + return + + for name in _real_functions: + test.stub_out('nova.compute.manager.ComputeManager.' + name, + _real_functions[name]) def _get_fake_cache(): diff --git a/nova/tests/unit/fake_processutils.py b/nova/tests/unit/fake_processutils.py index d45a7c1c38..a2705fde57 100644 --- a/nova/tests/unit/fake_processutils.py +++ b/nova/tests/unit/fake_processutils.py @@ -57,8 +57,6 @@ def fake_execute(*cmd_parts, **kwargs): It optionally executes a preconfigured function to return expected data. """ - global _fake_execute_repliers - process_input = kwargs.get('process_input', None) check_exit_code = kwargs.get('check_exit_code', 0) delay_on_retry = kwargs.get('delay_on_retry', True) diff --git a/nova/utils.py b/nova/utils.py index 41347bf5f7..aeee85b30c 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -765,8 +765,6 @@ def read_cached_file(filename, force_reload=False): :returns: A tuple with a boolean specifying if the data is fresh or not. """ - global _FILE_CACHE - if force_reload: delete_cached_file(filename) @@ -788,8 +786,6 @@ def delete_cached_file(filename): :param filename: filename to delete """ - global _FILE_CACHE - if filename in _FILE_CACHE: del _FILE_CACHE[filename]