Skip to content

Commit

Permalink
Handle type errors in nose/plugins/
Browse files Browse the repository at this point in the history
Minor adjustments to pass mypy. Mostly applying some missing
annotations.
For one of these, the fix is actually to annotate a type in
`nose2/events.py`.
  • Loading branch information
sirosen committed May 31, 2024
1 parent 67cf04d commit 9f88512
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion nose2/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# code developed in reference to that module and others within unittest2.
# unittest2 is Copyright (c) 2001-2010 Python Software Foundation; All
# Rights Reserved. See: http://docs.python.org/license.html
from __future__ import annotations

import argparse
import logging
Expand Down Expand Up @@ -315,7 +316,7 @@ class PluginInterface:
"handleDir",
# ... etc?
)
hookClass = Hook
hookClass: type[Hook] = Hook

def __init__(self):
self.hooks = {}
Expand Down
7 changes: 6 additions & 1 deletion nose2/plugins/loader/eggdiscovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
"""

from __future__ import annotations

import logging
import os
import types

from nose2 import events
from nose2.plugins.loader import discovery
Expand All @@ -23,7 +26,9 @@
log = logging.getLogger(__name__)

try:
import pkg_resources
import pkg_resources as _pkg_resources_mod

pkg_resources: types.ModuleType | None = _pkg_resources_mod
except ImportError:
pkg_resources = None

Expand Down
4 changes: 3 additions & 1 deletion nose2/plugins/printhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
each call.
"""

from __future__ import annotations

import sys

from nose2 import events

INDENT = []
INDENT: list[str] = []
__unittest = True


Expand Down

0 comments on commit 9f88512

Please sign in to comment.