From 2d03b01071a22c41837ccb9b4a1d05dabd90cf90 Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Mon, 9 Jun 2025 12:44:41 -0700 Subject: [PATCH] chore: update to mypy 1.16.0 and resolve issues found There was an error in the type-hints that was detected when updating to mypy 1.16.0 The error was: $ mypy gitlab/v4/cli.py:411: error: Argument 1 to "cls_to_gitlab_resource" has incompatible type "type[Any]"; expected "RESTObject" [arg-type] Found 1 error in 1 file (checked 246 source files) --- gitlab/cli.py | 2 +- gitlab/v4/cli.py | 2 +- requirements-lint.txt | 2 +- tests/unit/test_cli.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gitlab/cli.py b/gitlab/cli.py index a3ff5b5b4..ca4734190 100644 --- a/gitlab/cli.py +++ b/gitlab/cli.py @@ -107,7 +107,7 @@ def gitlab_resource_to_cls( return class_type -def cls_to_gitlab_resource(cls: RESTObject) -> str: +def cls_to_gitlab_resource(cls: type[RESTObject]) -> str: dasherized_uppercase = camel_upperlower_regex.sub(r"\1-\2", cls.__name__) dasherized_lowercase = camel_lowerupper_regex.sub(r"\1-\2", dasherized_uppercase) return dasherized_lowercase.lower() diff --git a/gitlab/v4/cli.py b/gitlab/v4/cli.py index 067a0a155..87fcaf261 100644 --- a/gitlab/v4/cli.py +++ b/gitlab/v4/cli.py @@ -394,7 +394,7 @@ def extend_parser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser: subparsers.required = True # populate argparse for all Gitlab Object - classes = set() + classes: set[type[gitlab.base.RESTObject]] = set() for cls in gitlab.v4.objects.__dict__.values(): if not isinstance(cls, type): continue diff --git a/requirements-lint.txt b/requirements-lint.txt index 0620fc57d..c8006e667 100644 --- a/requirements-lint.txt +++ b/requirements-lint.txt @@ -4,7 +4,7 @@ black==25.1.0 commitizen==4.8.2 flake8==7.2.0 isort==6.0.1 -mypy==1.15.0 +mypy==1.16.0 pylint==3.3.7 pytest==8.3.5 responses==0.25.7 diff --git a/tests/unit/test_cli.py b/tests/unit/test_cli.py index af3dd3380..cad27afba 100644 --- a/tests/unit/test_cli.py +++ b/tests/unit/test_cli.py @@ -161,7 +161,7 @@ def error(self, message): "Raise error instead of exiting on invalid arguments, to make testing easier" raise ValueError(message) - class Fake: + class Fake(gitlab.base.RESTObject): _id_attr = None class FakeManager(CreateMixin, UpdateMixin, gitlab.base.RESTManager):