diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 253a883..842b88a 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.4.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/astral-sh/ruff-pre-commit - rev: v0.5.5 + rev: v0.6.7 hooks: - id: ruff args: ['--fix', '--unsafe-fixes'] @@ -34,7 +34,7 @@ repos: # args: ['-l', '79'] # exclude: '^codegenerator/templates/.*$' - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.4.1 + rev: v1.11.2 hooks: - id: mypy language: python diff --git a/codegenerator/ansible.py b/codegenerator/ansible.py index dd6a558..4b1591a 100644 --- a/codegenerator/ansible.py +++ b/codegenerator/ansible.py @@ -42,7 +42,9 @@ class AnsibleGenerator(BaseGenerator): self._render(test_template, context, test_dest.parent, test_dest.name) - def generate(self, res, target_dir, args=None): + def generate( + self, res, target_dir, _openapi_spec=None, operation_id=None, args=None + ): """Generate code for the Ansible""" logging.debug(f"Generating Ansible code in {target_dir}") ansible_path = ["plugins", "modules"] diff --git a/codegenerator/cli.py b/codegenerator/cli.py index 9193550..e4419ee 100644 --- a/codegenerator/cli.py +++ b/codegenerator/cli.py @@ -24,12 +24,13 @@ from openstack import resource from sphinx import pycode import yaml -from codegenerator.ansible import AnsibleGenerator +# from codegenerator.ansible import AnsibleGenerator from codegenerator import common from codegenerator.jsonschema import JsonSchemaGenerator from codegenerator.metadata import MetadataGenerator from codegenerator.openapi_spec import OpenApiSchemaGenerator -from codegenerator.osc import OSCGenerator + +# from codegenerator.osc import OSCGenerator from codegenerator.rust_cli import RustCliGenerator from codegenerator.rust_sdk import RustSdkGenerator from codegenerator.types import Metadata @@ -193,8 +194,8 @@ def main(): ) generators = { - "osc": OSCGenerator(), - "ansible": AnsibleGenerator(), + # "osc": OSCGenerator(), + # "ansible": AnsibleGenerator(), "rust-sdk": RustSdkGenerator(), "rust-cli": RustCliGenerator(), "openapi-spec": OpenApiSchemaGenerator(), diff --git a/codegenerator/openapi/keystone.py b/codegenerator/openapi/keystone.py index 0d9b969..baeeadf 100644 --- a/codegenerator/openapi/keystone.py +++ b/codegenerator/openapi/keystone.py @@ -153,7 +153,7 @@ class KeystoneGenerator(OpenStackServerSourceBase): if route.rule.startswith("/static"): continue - self._process_route(route, openapi_spec) + self._process_route_keystone(route, openapi_spec) self._sanitize_param_ver_info(openapi_spec, self.min_api_version) @@ -170,7 +170,7 @@ class KeystoneGenerator(OpenStackServerSourceBase): return impl_path - def _process_route(self, route, openapi_spec): + def _process_route_keystone(self, route, openapi_spec): args = route.arguments # ep = route.endpoint view = self.app.view_functions[route.endpoint] @@ -345,7 +345,7 @@ class KeystoneGenerator(OpenStackServerSourceBase): operation_spec.tags.extend(operation_tags) operation_spec.tags = list(set(operation_spec.tags)) - self.process_operation( + self.process_operation_keystone( func, path, openapi_spec, @@ -356,7 +356,7 @@ class KeystoneGenerator(OpenStackServerSourceBase): return operation_spec - def process_operation( + def process_operation_keystone( self, func, path, diff --git a/codegenerator/openapi/neutron.py b/codegenerator/openapi/neutron.py index 826cad0..dd7de41 100644 --- a/codegenerator/openapi/neutron.py +++ b/codegenerator/openapi/neutron.py @@ -423,7 +423,7 @@ class NeutronGenerator(OpenStackServerSourceBase): # Tenant and Project quota is the same continue - self._process_route(route, openapi_spec, processed_routes) + self._process_route_neutron(route, openapi_spec, processed_routes) def _process_base_resource_routes(self, openapi_spec, processed_routes): """Process base resources exposed through Pecan""" @@ -438,7 +438,7 @@ class NeutronGenerator(OpenStackServerSourceBase): ("ports", "port"), ]: for method, action in [("GET", "index"), ("POST", "create")]: - self._process_route( + self._process_route_neutron( Route( coll, f"/{coll}", @@ -461,7 +461,7 @@ class NeutronGenerator(OpenStackServerSourceBase): ("DELETE", "delete"), ("PUT", "update"), ]: - self._process_route( + self._process_route_neutron( Route( coll, f"/{coll}/{{{res}_id}}", @@ -474,7 +474,7 @@ class NeutronGenerator(OpenStackServerSourceBase): processed_routes, controller=mgr.get_controller_for_resource(coll), ) - self._process_route( + self._process_route_neutron( Route( "port_allowed_address_pair", "/ports/{port_id}/add_allowed_address_pairs", @@ -488,7 +488,7 @@ class NeutronGenerator(OpenStackServerSourceBase): controller=mgr.get_controller_for_resource("ports"), ) - def _process_route( + def _process_route_neutron( self, route, openapi_spec, @@ -628,7 +628,7 @@ class NeutronGenerator(OpenStackServerSourceBase): if tag not in [x["name"] for x in openapi_spec.tags]: openapi_spec.tags.append({"name": tag}) - self.process_operation( + self.process_operation_neutron( func, openapi_spec, operation_spec, @@ -639,7 +639,7 @@ class NeutronGenerator(OpenStackServerSourceBase): method=method, ) - def process_operation( + def process_operation_neutron( self, func, openapi_spec, diff --git a/codegenerator/osc.py b/codegenerator/osc.py index 29a0c14..0a40a23 100644 --- a/codegenerator/osc.py +++ b/codegenerator/osc.py @@ -40,7 +40,9 @@ class OSCGenerator(BaseGenerator): self._render(test_template, context, test_dest.parent, test_dest.name) - def generate(self, res, target_dir, args=None): + def generate( + self, res, target_dir, _openapi_spec=None, operation_id=None, args=None + ): """Generate code for the OpenStackClient""" logging.debug(f"Generating OpenStackClient code in {target_dir}") osc_path = res.mod_name.split(".")[1:]