diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5677151b0..f5b3fa8fe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ default_language_version: python: python3 repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: trailing-whitespace - id: mixed-line-ending @@ -22,7 +22,7 @@ repos: hooks: - id: doc8 - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.4.0 hooks: - id: black args: ['-S', '-l', '79'] @@ -34,7 +34,7 @@ repos: - flake8-import-order~=0.18.2 exclude: '^(doc|releasenotes|tools)/.*$' - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.8.0 + rev: v1.9.0 hooks: - id: mypy additional_dependencies: diff --git a/openstack/block_storage/v3/_proxy.py b/openstack/block_storage/v3/_proxy.py index cf17a8f60..f3bfafaed 100644 --- a/openstack/block_storage/v3/_proxy.py +++ b/openstack/block_storage/v3/_proxy.py @@ -1780,8 +1780,7 @@ class Proxy(_base_proxy.BaseBlockStorageProxy): name_or_id: str, ignore_missing: ty.Literal[True] = True, **query, - ) -> ty.Optional[_service.Service]: - ... + ) -> ty.Optional[_service.Service]: ... @ty.overload def find_service( @@ -1789,8 +1788,7 @@ class Proxy(_base_proxy.BaseBlockStorageProxy): name_or_id: str, ignore_missing: ty.Literal[False], **query, - ) -> _service.Service: - ... + ) -> _service.Service: ... # excuse the duplication here: it's mypy's fault # https://github.com/python/mypy/issues/14764 @@ -1800,8 +1798,7 @@ class Proxy(_base_proxy.BaseBlockStorageProxy): name_or_id: str, ignore_missing: bool, **query, - ) -> ty.Optional[_service.Service]: - ... + ) -> ty.Optional[_service.Service]: ... def find_service( self, diff --git a/openstack/cloud/_security_group.py b/openstack/cloud/_security_group.py index d6d70a34f..a78bd578a 100644 --- a/openstack/cloud/_security_group.py +++ b/openstack/cloud/_security_group.py @@ -323,12 +323,12 @@ class SecurityGroupCloudMixin: # as the equivalent value. rule_def = { 'security_group_id': secgroup['id'], - 'port_range_min': None - if port_range_min == -1 - else port_range_min, - 'port_range_max': None - if port_range_max == -1 - else port_range_max, + 'port_range_min': ( + None if port_range_min == -1 else port_range_min + ), + 'port_range_max': ( + None if port_range_max == -1 else port_range_max + ), 'protocol': protocol, 'remote_ip_prefix': remote_ip_prefix, 'remote_group_id': remote_group_id, diff --git a/openstack/common/tag.py b/openstack/common/tag.py index e49a38268..0a2d16ec3 100644 --- a/openstack/common/tag.py +++ b/openstack/common/tag.py @@ -21,8 +21,7 @@ class TagMixin: _body: resource._ComponentManager @classmethod - def _get_session(cls, session): - ... + def _get_session(cls, session): ... _tag_query_parameters = { 'tags': 'tags', diff --git a/openstack/connection.py b/openstack/connection.py index 499cfd88e..a9d0d9392 100644 --- a/openstack/connection.py +++ b/openstack/connection.py @@ -558,9 +558,9 @@ class Connection( self.config._influxdb_config and 'additional_metric_tags' in self.config.config ): - self.config._influxdb_config[ - 'additional_metric_tags' - ] = self.config.config['additional_metric_tags'] + self.config._influxdb_config['additional_metric_tags'] = ( + self.config.config['additional_metric_tags'] + ) # Register cleanup steps atexit.register(self.close) diff --git a/openstack/image/_download.py b/openstack/image/_download.py index e15b8f2ad..fc4145cbf 100644 --- a/openstack/image/_download.py +++ b/openstack/image/_download.py @@ -41,8 +41,7 @@ class DownloadMixin: resource_response_key=None, microversion=None, **params, - ): - ... + ): ... def download( self, diff --git a/openstack/proxy.py b/openstack/proxy.py index c058964a9..5026cf2c9 100644 --- a/openstack/proxy.py +++ b/openstack/proxy.py @@ -484,8 +484,7 @@ class Proxy(adapter.Adapter): name_or_id: str, ignore_missing: ty.Literal[True] = True, **attrs, - ) -> ty.Optional[ResourceType]: - ... + ) -> ty.Optional[ResourceType]: ... @ty.overload def _find( @@ -494,8 +493,7 @@ class Proxy(adapter.Adapter): name_or_id: str, ignore_missing: ty.Literal[False], **attrs, - ) -> ResourceType: - ... + ) -> ResourceType: ... # excuse the duplication here: it's mypy's fault # https://github.com/python/mypy/issues/14764 @@ -506,8 +504,7 @@ class Proxy(adapter.Adapter): name_or_id: str, ignore_missing: bool, **attrs, - ) -> ty.Optional[ResourceType]: - ... + ) -> ty.Optional[ResourceType]: ... def _find( self, diff --git a/openstack/resource.py b/openstack/resource.py index 53b786176..76293f216 100644 --- a/openstack/resource.py +++ b/openstack/resource.py @@ -2258,8 +2258,7 @@ class Resource(dict): microversion: ty.Optional[str] = None, all_projects: ty.Optional[bool] = None, **params, - ) -> ty.Optional['Resource']: - ... + ) -> ty.Optional['Resource']: ... @ty.overload @classmethod @@ -2273,8 +2272,7 @@ class Resource(dict): microversion: ty.Optional[str] = None, all_projects: ty.Optional[bool] = None, **params, - ) -> 'Resource': - ... + ) -> 'Resource': ... # excuse the duplication here: it's mypy's fault # https://github.com/python/mypy/issues/14764 @@ -2290,8 +2288,7 @@ class Resource(dict): microversion: ty.Optional[str] = None, all_projects: ty.Optional[bool] = None, **params, - ): - ... + ): ... @classmethod def find( diff --git a/openstack/tests/base.py b/openstack/tests/base.py index 88cdebcbb..0882899b1 100644 --- a/openstack/tests/base.py +++ b/openstack/tests/base.py @@ -31,7 +31,6 @@ _TRUE_VALUES = ('true', '1', 'yes') class TestCase(base.BaseTestCase): - """Test case base class for all tests.""" # A way to adjust slow test classes diff --git a/openstack/tests/unit/cloud/test_role_assignment.py b/openstack/tests/unit/cloud/test_role_assignment.py index 23b5e3d51..45d213c7f 100644 --- a/openstack/tests/unit/cloud/test_role_assignment.py +++ b/openstack/tests/unit/cloud/test_role_assignment.py @@ -199,9 +199,11 @@ class TestRoleAssignment(base.TestCase): uri=self.get_mock_url(resource='users'), status_code=200, json={ - 'users': [user_data.json_response['user']] - if is_found - else [] + 'users': ( + [user_data.json_response['user']] + if is_found + else [] + ) }, ) ) @@ -215,9 +217,11 @@ class TestRoleAssignment(base.TestCase): ), status_code=200, json={ - 'users': [user_data.json_response['user']] - if is_found - else [] + 'users': ( + [user_data.json_response['user']] + if is_found + else [] + ) }, ) ) diff --git a/tox.ini b/tox.ini index 693535a1c..59493d19d 100644 --- a/tox.ini +++ b/tox.ini @@ -146,13 +146,14 @@ application-import-names = openstack # if they fix ALL of the occurances of one and only one of them. # E203 Black will put spaces after colons in list comprehensions # E501 Black takes care of line length for us +# E704 Black will occasionally put multiple statements on one line # H238 New Style Classes are the default in Python3 # H301 Black will put commas after imports that can't fit on one line # H4 Are about docstrings and there's just a huge pile of pre-existing issues. # W503 Is supposed to be off by default but in the latest pycodestyle isn't. # Also, both openstacksdk and Donald Knuth disagree with the rule. Line # breaks should occur before the binary operator for readability. -ignore = E203, E501, H301, H238, H4, W503 +ignore = E203, E501, E704, H301, H238, H4, W503 import-order-style = pep8 show-source = True exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,openstack/_services_mixin.py