Skip to content

chore: remove duplicate/no-op tests from meta/test_ensure_type_hints #1707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion requirements-lint.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ pytest
types-PyYAML==6.0.1
types-requests==2.26.0
types-setuptools==57.4.3
types-toml==0.10.1
28 changes: 7 additions & 21 deletions tests/meta/test_ensure_type_hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from typing import Tuple, Type

import _pytest
import toml

import gitlab.mixins
import gitlab.v4.objects
Expand All @@ -18,20 +17,8 @@ def pytest_generate_tests(metafunc: _pytest.python.Metafunc) -> None:
"""Find all of the classes in gitlab.v4.objects and pass them to our test
function"""

# Ignore any modules that we are ignoring in our pyproject.toml
excluded_modules = set()
with open("pyproject.toml", "r") as in_file:
pyproject = toml.load(in_file)
overrides = pyproject.get("tool", {}).get("mypy", {}).get("overrides", [])
for override in overrides:
if not override.get("ignore_errors"):
continue
for module in override.get("module", []):
if module.startswith("gitlab.v4.objects"):
excluded_modules.add(module)

class_info_list = []
for module_name, module_value in inspect.getmembers(gitlab.v4.objects):
class_info_set = set()
for _, module_value in inspect.getmembers(gitlab.v4.objects):
if not inspect.ismodule(module_value):
# We only care about the modules
continue
Expand All @@ -41,17 +28,16 @@ def pytest_generate_tests(metafunc: _pytest.python.Metafunc) -> None:
continue

module_name = class_value.__module__
# Ignore modules that mypy is ignoring
if module_name in excluded_modules:
continue

# Ignore imported classes from gitlab.base
if module_name == "gitlab.base":
continue

class_info_list.append((class_name, class_value))
if not class_name.endswith("Manager"):
continue

class_info_set.add((class_name, class_value))

metafunc.parametrize("class_info", class_info_list)
metafunc.parametrize("class_info", class_info_set)


class TestTypeHints:
Expand Down