From 63e0a048f4933beea8f6c86af7363d744082382b Mon Sep 17 00:00:00 2001 From: Stephen Rosen Date: Thu, 30 May 2024 21:50:57 -0500 Subject: [PATCH] Set the type of Event._attrs This fixes a number of mypy errors. Additionally, replace a lambda to allow for better type inference (removes a misc mypy error). --- nose2/events.py | 3 ++- nose2/tests/unit/test_prof_plugin.py | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/nose2/events.py b/nose2/events.py index b7ba20c9..272880e4 100644 --- a/nose2/events.py +++ b/nose2/events.py @@ -7,6 +7,7 @@ import argparse import logging +import typing as t import unittest from nose2 import config, util @@ -363,7 +364,7 @@ class Event: """ - _attrs = ("handled",) + _attrs: t.ClassVar[tuple[str, ...]] = ("handled",) version = "0.4" def __init__(self, **metadata): diff --git a/nose2/tests/unit/test_prof_plugin.py b/nose2/tests/unit/test_prof_plugin.py index 02f5ab4a..bf18aad1 100644 --- a/nose2/tests/unit/test_prof_plugin.py +++ b/nose2/tests/unit/test_prof_plugin.py @@ -22,7 +22,11 @@ def tearDown(self): def test_startTestRun_sets_executeTests(self): _prof = Stub() _prof.runcall = object() - prof.cProfile.Profile = lambda: _prof + + def _profile_call() -> Stub: + return _prof + + prof.cProfile.Profile = _profile_call event = StartTestRunEvent( runner=None, suite=None, result=None, startTime=None, executeTests=None )