From d54866abb55fffac271a84647b7c009d7eeff924 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 17:03:39 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- nose2/config.py | 2 +- nose2/events.py | 74 +++++++++---------- nose2/loader.py | 2 +- nose2/main.py | 2 +- nose2/plugins/attrib.py | 4 +- nose2/plugins/buffer.py | 4 +- nose2/plugins/coverage.py | 2 +- nose2/plugins/debugger.py | 2 +- nose2/plugins/doctests.py | 2 +- nose2/plugins/junitxml.py | 2 +- nose2/plugins/layers.py | 2 +- nose2/plugins/loader/discovery.py | 2 +- nose2/plugins/loader/generators.py | 2 +- nose2/plugins/loader/parameters.py | 2 +- nose2/plugins/loader/testclasses.py | 2 +- nose2/plugins/logcapture.py | 6 +- nose2/plugins/mp.py | 10 +-- nose2/plugins/outcomes.py | 2 +- nose2/plugins/prettyassert.py | 2 +- nose2/plugins/prof.py | 2 +- nose2/plugins/result.py | 2 +- nose2/plugins/testid.py | 2 +- nose2/result.py | 2 +- nose2/runner.py | 2 +- nose2/session.py | 2 +- nose2/sphinxext.py | 6 +- nose2/suite.py | 2 +- nose2/tests/_common.py | 18 ++--- .../tests/functional/support/lib/plugin_a.py | 2 +- .../test_class_fail/test_class_fail.py | 2 +- .../tests/functional/test_discovery_loader.py | 2 +- nose2/tests/functional/test_util.py | 2 +- nose2/tests/unit/test_buffer_plugin.py | 2 +- nose2/tests/unit/test_debugger_plugin.py | 2 +- nose2/tests/unit/test_loader.py | 2 +- nose2/tests/unit/test_logcapture_plugin.py | 4 +- nose2/tests/unit/test_outcomes_plugin.py | 2 +- nose2/tests/unit/test_printhooks_plugin.py | 2 +- nose2/tests/unit/test_testclass_loader.py | 2 +- nose2/tools/such.py | 6 +- nose2/util.py | 2 +- pyproject.toml | 1 + 42 files changed, 99 insertions(+), 98 deletions(-) diff --git a/nose2/config.py b/nose2/config.py index 8df02257..1b407e7e 100644 --- a/nose2/config.py +++ b/nose2/config.py @@ -11,7 +11,7 @@ class Config: """ - def __init__(self, items): + def __init__(self, items) -> None: self._items = items self._mvd = {} for k, v in items: diff --git a/nose2/events.py b/nose2/events.py index 272880e4..06969709 100644 --- a/nose2/events.py +++ b/nose2/events.py @@ -224,7 +224,7 @@ class Hook: """ - def __init__(self, method): + def __init__(self, method) -> None: self.method = method self.plugins = [] @@ -319,7 +319,7 @@ class PluginInterface: ) hookClass: type[Hook] = Hook - def __init__(self): + def __init__(self) -> None: self.hooks = {} def addMethod(self, method): @@ -367,7 +367,7 @@ class Event: _attrs: t.ClassVar[tuple[str, ...]] = ("handled",) version = "0.4" - def __init__(self, **metadata): + def __init__(self, **metadata) -> None: self.handled = False self.metadata = {} self.metadata.update(metadata) @@ -413,7 +413,7 @@ class PluginsLoadedEvent(Event): _attrs = Event._attrs + ("pluginsLoaded",) - def __init__(self, pluginsLoaded, **kw): + def __init__(self, pluginsLoaded, **kw) -> None: self.pluginsLoaded = pluginsLoaded super().__init__(**kw) @@ -430,7 +430,7 @@ class RunnerCreatedEvent(Event): _attrs = Event._attrs + ("runner",) - def __init__(self, runner, **kw): + def __init__(self, runner, **kw) -> None: self.runner = runner super().__init__(**kw) @@ -447,7 +447,7 @@ class ResultCreatedEvent(Event): _attrs = Event._attrs + ("result",) - def __init__(self, result, **kw): + def __init__(self, result, **kw) -> None: self.result = result super().__init__(**kw) @@ -462,7 +462,7 @@ class StartLayerSetupEvent(Event): _attrs = Event._attrs + ("layer",) - def __init__(self, layer, **kw): + def __init__(self, layer, **kw) -> None: self.layer = layer super().__init__(**kw) @@ -477,7 +477,7 @@ class StopLayerSetupEvent(Event): _attrs = Event._attrs + ("layer",) - def __init__(self, layer, **kw): + def __init__(self, layer, **kw) -> None: self.layer = layer super().__init__(**kw) @@ -496,7 +496,7 @@ class StartLayerSetupTestEvent(Event): _attrs = Event._attrs + ("layer", "test") - def __init__(self, layer, test, **kw): + def __init__(self, layer, test, **kw) -> None: self.layer = layer self.test = test super().__init__(**kw) @@ -516,7 +516,7 @@ class StopLayerSetupTestEvent(Event): _attrs = Event._attrs + ("layer", "test") - def __init__(self, layer, test, **kw): + def __init__(self, layer, test, **kw) -> None: self.layer = layer self.test = test super().__init__(**kw) @@ -532,7 +532,7 @@ class StartLayerTeardownEvent(Event): _attrs = Event._attrs + ("layer",) - def __init__(self, layer, **kw): + def __init__(self, layer, **kw) -> None: self.layer = layer super().__init__(**kw) @@ -547,7 +547,7 @@ class StopLayerTeardownEvent(Event): _attrs = Event._attrs + ("layer",) - def __init__(self, layer, **kw): + def __init__(self, layer, **kw) -> None: self.layer = layer super().__init__(**kw) @@ -566,7 +566,7 @@ class StartLayerTeardownTestEvent(Event): _attrs = Event._attrs + ("layer", "test") - def __init__(self, layer, test, **kw): + def __init__(self, layer, test, **kw) -> None: self.layer = layer self.test = test super().__init__(**kw) @@ -586,7 +586,7 @@ class StopLayerTeardownTestEvent(Event): _attrs = Event._attrs + ("layer", "test") - def __init__(self, layer, test, **kw): + def __init__(self, layer, test, **kw) -> None: self.layer = layer self.test = test super().__init__(**kw) @@ -633,7 +633,7 @@ def execute(suite, result): _attrs = Event._attrs + ("runner", "suite", "result", "startTime", "executeTests") - def __init__(self, runner, suite, result, startTime, executeTests, **kw): + def __init__(self, runner, suite, result, startTime, executeTests, **kw) -> None: self.suite = suite self.runner = runner self.result = result @@ -665,7 +665,7 @@ class StopTestRunEvent(Event): _attrs = Event._attrs + ("runner", "result", "stopTime", "timeTaken") - def __init__(self, runner, result, stopTime, timeTaken, **kw): + def __init__(self, runner, result, stopTime, timeTaken, **kw) -> None: self.runner = runner self.result = result self.stopTime = stopTime @@ -692,7 +692,7 @@ class StartTestEvent(Event): _attrs = Event._attrs + ("test", "result", "startTime") - def __init__(self, test, result, startTime, **kw): + def __init__(self, test, result, startTime, **kw) -> None: self.test = test self.result = result self.startTime = startTime @@ -718,7 +718,7 @@ class StopTestEvent(Event): _attrs = Event._attrs + ("test", "result", "stopTime") - def __init__(self, test, result, stopTime, **kw): + def __init__(self, test, result, stopTime, **kw) -> None: self.test = test self.result = result self.stopTime = stopTime @@ -799,7 +799,7 @@ def __init__( shortLabel=None, longLabel=None, **kw, - ): + ) -> None: self.test = test self.result = result self.outcome = outcome @@ -837,7 +837,7 @@ class LoadFromModuleEvent(Event): _attrs = Event._attrs + ("loader", "module", "extraTests") - def __init__(self, loader, module, **kw): + def __init__(self, loader, module, **kw) -> None: self.loader = loader self.module = module self.extraTests = [] @@ -847,7 +847,7 @@ def __init__(self, loader, module, **kw): class ModuleSuiteEvent(Event): _attrs = Event._attrs + ("loader", "module", "suite") - def __init__(self, loader, module, suite, **kw): + def __init__(self, loader, module, suite, **kw) -> None: self.loader = loader self.module = module self.suite = suite @@ -880,7 +880,7 @@ class LoadFromTestCaseEvent(Event): _attrs = Event._attrs + ("loader", "testCase", "extraTests") - def __init__(self, loader, testCase, **kw): + def __init__(self, loader, testCase, **kw) -> None: self.loader = loader self.testCase = testCase self.extraTests = [] @@ -918,7 +918,7 @@ class LoadFromNamesEvent(Event): _attrs = Event._attrs + ("loader", "names", "module", "extraTests") - def __init__(self, loader, names, module, **kw): + def __init__(self, loader, names, module, **kw) -> None: self.loader = loader self.names = names self.module = module @@ -960,7 +960,7 @@ class LoadFromNameEvent(Event): _attrs = Event._attrs + ("loader", "name", "module", "extraTests") - def __init__(self, loader, name, module, **kw): + def __init__(self, loader, name, module, **kw) -> None: self.loader = loader self.name = name self.module = module @@ -1012,7 +1012,7 @@ class HandleFileEvent(Event): _attrs = Event._attrs + ("loader", "name", "path", "pattern", "topLevelDirectory") - def __init__(self, loader, name, path, pattern, topLevelDirectory, **kw): + def __init__(self, loader, name, path, pattern, topLevelDirectory, **kw) -> None: self.extraTests = [] self.path = path self.loader = loader @@ -1046,7 +1046,7 @@ class MatchPathEvent(Event): _attrs = Event._attrs + ("name", "path", "pattern") - def __init__(self, name, path, pattern, **kw): + def __init__(self, name, path, pattern, **kw) -> None: self.path = path self.name = name self.pattern = pattern @@ -1101,7 +1101,7 @@ class GetTestCaseNamesEvent(Event): "isTestMethod", ) - def __init__(self, loader, testCase, isTestMethod, **kw): + def __init__(self, loader, testCase, isTestMethod, **kw) -> None: self.loader = loader self.testCase = testCase self.testMethodPrefix = None @@ -1134,7 +1134,7 @@ class ResultSuccessEvent(Event): _attrs = Event._attrs + ("result", "success") - def __init__(self, result, success, **kw): + def __init__(self, result, success, **kw) -> None: self.result = result self.success = success super().__init__(**kw) @@ -1158,7 +1158,7 @@ class ResultStopEvent(Event): _attrs = Event._attrs + ("result", "shouldStop") - def __init__(self, result, shouldStop, **kw): + def __init__(self, result, shouldStop, **kw) -> None: self.result = result self.shouldStop = shouldStop super().__init__(**kw) @@ -1185,7 +1185,7 @@ class DescribeTestEvent(Event): _attrs = Event._attrs + ("test", "description") - def __init__(self, test, description=None, errorList=False, **kw): + def __init__(self, test, description=None, errorList=False, **kw) -> None: self.test = test self.description = description self.errorList = errorList @@ -1210,7 +1210,7 @@ class OutcomeDetailEvent(Event): _attrs = Event._attrs + ("outcomeEvent", "extraDetail") - def __init__(self, outcomeEvent, **kw): + def __init__(self, outcomeEvent, **kw) -> None: self.outcomeEvent = outcomeEvent self.extraDetail = [] super().__init__(**kw) @@ -1239,7 +1239,7 @@ class ReportSummaryEvent(Event): _attrs = Event._attrs + ("stopTestEvent", "stream", "reportCategories") - def __init__(self, stopTestEvent, stream, reportCategories, **kw): + def __init__(self, stopTestEvent, stream, reportCategories, **kw) -> None: self.stopTestEvent = stopTestEvent self.stream = stream self.reportCategories = reportCategories @@ -1266,7 +1266,7 @@ class ReportTestEvent(Event): _attrs = Event._attrs + ("testEvent", "stream") - def __init__(self, testEvent, stream, **kw): + def __init__(self, testEvent, stream, **kw) -> None: self.testEvent = testEvent self.stream = stream super().__init__(**kw) @@ -1284,7 +1284,7 @@ class UserInteractionEvent(Event): """ - def __init__(self, **kw): + def __init__(self, **kw) -> None: super().__init__(**kw) @@ -1308,7 +1308,7 @@ class CommandLineArgsEvent(Event): _attrs = Event._attrs + ("args",) - def __init__(self, args, **kw): + def __init__(self, args, **kw) -> None: self.args = args super().__init__(**kw) @@ -1336,7 +1336,7 @@ class CreateTestsEvent(Event): _attrs = Event._attrs + ("loader", "testNames", "module") - def __init__(self, loader, testNames, module, **kw): + def __init__(self, loader, testNames, module, **kw) -> None: self.loader = loader self.testNames = testNames self.module = module @@ -1357,6 +1357,6 @@ class CreatedTestSuiteEvent(Event): _attrs = Event._attrs + ("suite",) - def __init__(self, suite, **kw): + def __init__(self, suite, **kw) -> None: self.suite = suite super().__init__(**kw) diff --git a/nose2/loader.py b/nose2/loader.py index c41464fc..460464a3 100644 --- a/nose2/loader.py +++ b/nose2/loader.py @@ -27,7 +27,7 @@ class PluggableTestLoader: suiteClass = unittest.TestSuite - def __init__(self, session): + def __init__(self, session) -> None: self.session = session def loadTestsFromModule(self, module): diff --git a/nose2/main.py b/nose2/main.py index 08b3cedb..dbb834fa 100644 --- a/nose2/main.py +++ b/nose2/main.py @@ -75,7 +75,7 @@ class PluggableTestProgram(unittest.TestProgram): excludePlugins = () # XXX override __init__ to warn that testLoader and testRunner are ignored? - def __init__(self, **kw): + def __init__(self, **kw) -> None: plugins = kw.pop("plugins", []) exclude = kw.pop("excludePlugins", []) hooks = kw.pop("extraHooks", []) diff --git a/nose2/plugins/attrib.py b/nose2/plugins/attrib.py index c117da92..caca3125 100644 --- a/nose2/plugins/attrib.py +++ b/nose2/plugins/attrib.py @@ -10,7 +10,7 @@ class AttributeSelector(Plugin): """Filter tests by attribute""" - def __init__(self): + def __init__(self) -> None: self.attribs = [] self.eval_attribs = [] self.addArgument( @@ -154,7 +154,7 @@ def _get_attr(test, key): class ContextHelper: - def __init__(self, obj): + def __init__(self, obj) -> None: self.obj = obj def __getitem__(self, name): diff --git a/nose2/plugins/buffer.py b/nose2/plugins/buffer.py index a49585e9..bf397314 100644 --- a/nose2/plugins/buffer.py +++ b/nose2/plugins/buffer.py @@ -24,7 +24,7 @@ class _Buffer: - def __init__(self, stream): + def __init__(self, stream) -> None: self._stream = stream self._buffer = io.StringIO() @@ -56,7 +56,7 @@ class OutputBufferPlugin(events.Plugin): commandLineSwitch = ("B", "output-buffer", "Enable output buffer") configSection = "output-buffer" - def __init__(self): + def __init__(self) -> None: self.captureStdout = self.config.as_bool("stdout", default=True) self.captureStderr = self.config.as_bool("stderr", default=False) self.bufStdout = self.bufStderr = None diff --git a/nose2/plugins/coverage.py b/nose2/plugins/coverage.py index 77dba825..1a057c9d 100644 --- a/nose2/plugins/coverage.py +++ b/nose2/plugins/coverage.py @@ -43,7 +43,7 @@ class Coverage(Plugin): _mpmode = False _subprocess = False - def __init__(self): + def __init__(self) -> None: """Get our config and add our command line arguments.""" # tracking var for any decision which marks the entire run as failed self.decided_failure = False diff --git a/nose2/plugins/debugger.py b/nose2/plugins/debugger.py index c2a782e5..991649cf 100644 --- a/nose2/plugins/debugger.py +++ b/nose2/plugins/debugger.py @@ -35,7 +35,7 @@ class Debugger(events.Plugin): # allow easy mocking and replacement of pdb pdb = pdb - def __init__(self): + def __init__(self) -> None: self.errorsOnly = self.config.as_bool("errors-only", default=False) def testOutcome(self, event): diff --git a/nose2/plugins/doctests.py b/nose2/plugins/doctests.py index d644b07a..598133ae 100644 --- a/nose2/plugins/doctests.py +++ b/nose2/plugins/doctests.py @@ -30,7 +30,7 @@ class DocTestLoader(Plugin): "Load doctests from text files and modules", ) - def __init__(self): + def __init__(self) -> None: self.extensions = self.config.as_list("extensions", [".txt", ".rst"]) def handleFile(self, event): diff --git a/nose2/plugins/junitxml.py b/nose2/plugins/junitxml.py index bd3bbc19..dde98276 100644 --- a/nose2/plugins/junitxml.py +++ b/nose2/plugins/junitxml.py @@ -102,7 +102,7 @@ class JUnitXmlReporter(events.Plugin): configSection = "junit-xml" commandLineSwitch = ("X", "junit-xml", "Generate junit-xml output report") - def __init__(self): + def __init__(self) -> None: # Read argument from configuration file, or filled with default self.path = os.path.realpath( self.config.as_str("path", default="nose2-junit.xml") diff --git a/nose2/plugins/layers.py b/nose2/plugins/layers.py index 190b30ea..4166bc99 100644 --- a/nose2/plugins/layers.py +++ b/nose2/plugins/layers.py @@ -198,7 +198,7 @@ class LayerReporter(events.Plugin): ) configSection = "layer-reporter" - def __init__(self): + def __init__(self) -> None: self.indent = self.config.as_str("indent", " ") self.colors = self.config.as_bool("colors", False) self.highlight_words = self.config.as_list( diff --git a/nose2/plugins/loader/discovery.py b/nose2/plugins/loader/discovery.py index 24654ae8..ed2610a0 100644 --- a/nose2/plugins/loader/discovery.py +++ b/nose2/plugins/loader/discovery.py @@ -31,7 +31,7 @@ class DirectoryHandler: - def __init__(self, session): + def __init__(self, session) -> None: self.session = session self.event_handled = False diff --git a/nose2/plugins/loader/generators.py b/nose2/plugins/loader/generators.py index a367ec48..c38c69f2 100644 --- a/nose2/plugins/loader/generators.py +++ b/nose2/plugins/loader/generators.py @@ -228,7 +228,7 @@ def createTest(name): class GeneratorFunctionCase(unittest.FunctionTestCase): - def __init__(self, name, **args): + def __init__(self, name, **args) -> None: self._funcName = name unittest.FunctionTestCase.__init__(self, None, **args) diff --git a/nose2/plugins/loader/parameters.py b/nose2/plugins/loader/parameters.py index 4797faff..2e1ea4a1 100644 --- a/nose2/plugins/loader/parameters.py +++ b/nose2/plugins/loader/parameters.py @@ -56,7 +56,7 @@ def testExtraArg(case, bar, foo): class ParamsFunctionCase(unittest.FunctionTestCase): - def __init__(self, name, func, **args): + def __init__(self, name, func, **args) -> None: self._funcName = name unittest.FunctionTestCase.__init__(self, func, **args) diff --git a/nose2/plugins/loader/testclasses.py b/nose2/plugins/loader/testclasses.py index 3e98674e..49226863 100644 --- a/nose2/plugins/loader/testclasses.py +++ b/nose2/plugins/loader/testclasses.py @@ -194,7 +194,7 @@ def isTestMethod(attrname, cls=cls, excluded=excluded): # hide it inside of a factory func. ugly! def MethodTestCase(cls): class _MethodTestCase(unittest.TestCase): - def __init__(self, method): + def __init__(self, method) -> None: self.method = method self._name = f"{cls.__module__}.{cls.__name__}.{method}" self.obj = cls() diff --git a/nose2/plugins/logcapture.py b/nose2/plugins/logcapture.py index b019b058..8273021c 100644 --- a/nose2/plugins/logcapture.py +++ b/nose2/plugins/logcapture.py @@ -31,7 +31,7 @@ class LogCapture(Plugin): clear = False filters = ["-nose"] - def __init__(self): + def __init__(self) -> None: self.logformat = self.config.as_str("format", self.logformat) self.logdatefmt = self.config.as_str("date-format", self.logdatefmt) self.filters = self.config.as_list("filter", self.filters) @@ -104,7 +104,7 @@ def _addCapturedLogs(self, event): class FilterSet: - def __init__(self, filter_components): + def __init__(self, filter_components) -> None: self.inclusive, self.exclusive = self._partition(filter_components) @staticmethod @@ -146,7 +146,7 @@ def _deny(self, record): class MyMemoryHandler(BufferingHandler): - def __init__(self, capacity, logformat, logdatefmt, filters): + def __init__(self, capacity, logformat, logdatefmt, filters) -> None: BufferingHandler.__init__(self, capacity) fmt = logging.Formatter(logformat, logdatefmt) self.setFormatter(fmt) diff --git a/nose2/plugins/mp.py b/nose2/plugins/mp.py index f80b3930..0d02a40b 100644 --- a/nose2/plugins/mp.py +++ b/nose2/plugins/mp.py @@ -15,7 +15,7 @@ class MultiProcess(events.Plugin): configSection = "multiprocess" - def __init__(self): + def __init__(self) -> None: self.addArgument( self.setProcs, "N", @@ -433,7 +433,7 @@ def execute(suite, result): """ - def __init__(self, loader, result, runner, plugins, connection, **metadata): + def __init__(self, loader, result, runner, plugins, connection, **metadata) -> None: self.loader = loader self.result = result self.runner = runner @@ -457,14 +457,14 @@ def registerInSubprocess(self, event): """ - def __init__(self, **metadata): + def __init__(self, **metadata) -> None: self.pluginClasses = [] super().__init__(**metadata) # custom hook system that records calls and events class RecordingHook(events.Hook): - def __init__(self, method, interface): + def __init__(self, method, interface) -> None: super().__init__(method) self.interface = interface @@ -485,7 +485,7 @@ class RecordingPluginInterface(events.PluginInterface): "getTestMethodNames", } - def __init__(self): + def __init__(self) -> None: super().__init__() self.events = [] diff --git a/nose2/plugins/outcomes.py b/nose2/plugins/outcomes.py index 0a6dc89d..672d9751 100644 --- a/nose2/plugins/outcomes.py +++ b/nose2/plugins/outcomes.py @@ -33,7 +33,7 @@ class Outcomes(Plugin): "Treat some configured exceptions as failure or skips", ) - def __init__(self): + def __init__(self) -> None: self.treatAsFail = set(self.config.as_list("treat-as-fail", [])) self.treatAsSkip = set(self.config.as_list("treat-as-skip", [])) diff --git a/nose2/plugins/prettyassert.py b/nose2/plugins/prettyassert.py index d923f6ca..573e208c 100644 --- a/nose2/plugins/prettyassert.py +++ b/nose2/plugins/prettyassert.py @@ -245,7 +245,7 @@ def _tokenize_assert(source_lines, frame_locals, frame_globals): class TokenProcessor: - def __init__(self, frame_locals, frame_globals): + def __init__(self, frame_locals, frame_globals) -> None: # local and global variables from the frame which we're inspecting self.frame_locals, self.frame_globals = frame_locals, frame_globals diff --git a/nose2/plugins/prof.py b/nose2/plugins/prof.py index 4114cfe2..f8a5197d 100644 --- a/nose2/plugins/prof.py +++ b/nose2/plugins/prof.py @@ -32,7 +32,7 @@ class Profiler(events.Plugin): configSection = "profiler" commandLineSwitch = ("P", "profile", "Run tests under profiler") - def __init__(self): + def __init__(self) -> None: self.pfile = self.config.as_str("filename", "") self.sort = self.config.as_str("sort", "cumulative") self.restrict = self.config.as_list("restrict", []) diff --git a/nose2/plugins/result.py b/nose2/plugins/result.py index e13282d7..cab62d73 100644 --- a/nose2/plugins/result.py +++ b/nose2/plugins/result.py @@ -42,7 +42,7 @@ class ResultReporter(events.Plugin): separator1 = "=" * 70 separator2 = "-" * 70 - def __init__(self): + def __init__(self) -> None: self.testsRun = 0 self.reportCategories = { "failures": [], diff --git a/nose2/plugins/testid.py b/nose2/plugins/testid.py index 646bcb25..2655b3c8 100644 --- a/nose2/plugins/testid.py +++ b/nose2/plugins/testid.py @@ -28,7 +28,7 @@ class TestId(Plugin): commandLineSwitch = ("I", "with-id", "Add test ids to output") idpat = re.compile(r"(\d+)") - def __init__(self): + def __init__(self) -> None: self.idfile = self.config.as_str("id-file", ".noseids") self.ids = {} self.tests = {} diff --git a/nose2/result.py b/nose2/result.py index 4fd5e73d..1baf5423 100644 --- a/nose2/result.py +++ b/nose2/result.py @@ -25,7 +25,7 @@ class PluggableTestResult: """ - def __init__(self, session): + def __init__(self, session) -> None: self.session = session self.shouldStop = False # XXX TestCase.subTest expects a result.failfast attribute diff --git a/nose2/runner.py b/nose2/runner.py index 4790e897..532895b8 100644 --- a/nose2/runner.py +++ b/nose2/runner.py @@ -24,7 +24,7 @@ class PluggableTestRunner: resultClass = result.PluggableTestResult - def __init__(self, session): + def __init__(self, session) -> None: self.session = session def run(self, test): diff --git a/nose2/session.py b/nose2/session.py index d6e527eb..408b5c61 100644 --- a/nose2/session.py +++ b/nose2/session.py @@ -73,7 +73,7 @@ class Session: configClass = config.Config - def __init__(self): + def __init__(self) -> None: self.argparse = argparse.ArgumentParser(prog="nose2", add_help=False) self.pluginargs = self.argparse.add_argument_group( "plugin arguments", "Command-line arguments added by plugins:" diff --git a/nose2/sphinxext.py b/nose2/sphinxext.py index 4888fb66..26c83510 100644 --- a/nose2/sphinxext.py +++ b/nose2/sphinxext.py @@ -172,7 +172,7 @@ def setup(app): class ConfigBucket: - def __init__(self): + def __init__(self) -> None: self.section = None self.vars = {} @@ -218,7 +218,7 @@ def get(self, item, default=DEFAULT): class OptBucket: - def __init__(self, doc=None, prog="nosetests"): + def __init__(self, doc=None, prog="nosetests") -> None: self.seen = set() self.opts = [] self.doc = doc @@ -245,7 +245,7 @@ def __call__(self, callback, opt=None, longOpt=None, help=None): class Opt: - def __init__(self, *arg, **kw): + def __init__(self, *arg, **kw) -> None: self.opts = arg self.action = kw.pop("action", None) self.default = kw.pop("default", None) diff --git a/nose2/suite.py b/nose2/suite.py index 034c27e0..be04ef55 100644 --- a/nose2/suite.py +++ b/nose2/suite.py @@ -14,7 +14,7 @@ class LayerSuite(unittest.BaseTestSuite): - def __init__(self, session, tests=(), layer=None): + def __init__(self, session, tests=(), layer=None) -> None: super().__init__(tests) self.layer = layer self.wasSetup = False diff --git a/nose2/tests/_common.py b/nose2/tests/_common.py index c7b1f6ae..5cd40d7c 100644 --- a/nose2/tests/_common.py +++ b/nose2/tests/_common.py @@ -104,7 +104,7 @@ def runModuleAsMain(self, testmodule, *args): class _FakeEventBase: """Baseclass for fake :class:`~nose2.events.Event`s.""" - def __init__(self): + def __init__(self) -> None: self.handled = False self.version = "0.1" self.metadata = {} @@ -113,7 +113,7 @@ def __init__(self): class FakeHandleFileEvent(_FakeEventBase): """Fake HandleFileEvent.""" - def __init__(self, name): + def __init__(self, name) -> None: super().__init__() self.loader = Stub() # FIXME @@ -125,7 +125,7 @@ def __init__(self, name): class FakeStartTestEvent(_FakeEventBase): """Fake :class:`~nose2.events.StartTestEvent`.""" - def __init__(self, test): + def __init__(self, test) -> None: super().__init__() self.test = test self.result = test.defaultTestResult() @@ -137,7 +137,7 @@ def __init__(self, test): class FakeLoadFromNameEvent(_FakeEventBase): """Fake :class:`~nose2.events.LoadFromNameEvent`.""" - def __init__(self, name): + def __init__(self, name) -> None: super().__init__() self.name = name @@ -145,7 +145,7 @@ def __init__(self, name): class FakeLoadFromNamesEvent(_FakeEventBase): """Fake :class:`~nose2.events.LoadFromNamesEvent`.""" - def __init__(self, names): + def __init__(self, names) -> None: super().__init__() self.names = names @@ -155,7 +155,7 @@ class FakeStartTestRunEvent(_FakeEventBase): def __init__( self, runner=None, suite=None, result=None, startTime=None, executeTests=None - ): + ) -> None: super().__init__() self.suite = suite self.runner = runner @@ -197,7 +197,7 @@ def run_module_as_main(test_module, *args): class NotReallyAProc: - def __init__(self, args, cwd=None, **kwargs): + def __init__(self, args, cwd=None, **kwargs) -> None: self.args = args self.chdir = cwd self.kwargs = kwargs @@ -249,7 +249,7 @@ class RedirectStdStreams: buffers. """ - def __init__(self): + def __init__(self) -> None: self.stdout = io.StringIO() self.stderr = io.StringIO() @@ -269,7 +269,7 @@ def __exit__(self, exc_type, exc_value, traceback): # mock multiprocessing Connection class Conn: - def __init__(self, items): + def __init__(self, items) -> None: self.items = items self.sent = [] self.closed = False diff --git a/nose2/tests/functional/support/lib/plugin_a.py b/nose2/tests/functional/support/lib/plugin_a.py index f12cbc97..07a9d2a7 100644 --- a/nose2/tests/functional/support/lib/plugin_a.py +++ b/nose2/tests/functional/support/lib/plugin_a.py @@ -4,5 +4,5 @@ class PluginA(events.Plugin): configSection = "a" - def __init__(self): + def __init__(self) -> None: self.a = self.config.as_int("a", 0) diff --git a/nose2/tests/functional/support/scenario/test_class_fail/test_class_fail.py b/nose2/tests/functional/support/scenario/test_class_fail/test_class_fail.py index 95ec817a..4109eb43 100644 --- a/nose2/tests/functional/support/scenario/test_class_fail/test_class_fail.py +++ b/nose2/tests/functional/support/scenario/test_class_fail/test_class_fail.py @@ -1,5 +1,5 @@ class Test: - def __init__(self): + def __init__(self) -> None: raise RuntimeError( "Something bad happened but other tests should still be run!" ) diff --git a/nose2/tests/functional/test_discovery_loader.py b/nose2/tests/functional/test_discovery_loader.py index cc56abb5..87bf2844 100644 --- a/nose2/tests/functional/test_discovery_loader.py +++ b/nose2/tests/functional/test_discovery_loader.py @@ -4,7 +4,7 @@ class Watcher(events.Plugin): - def __init__(self): + def __init__(self) -> None: self.called = [] def loadTestsFromModule(self, event): diff --git a/nose2/tests/functional/test_util.py b/nose2/tests/functional/test_util.py index f412c59d..1f29d9eb 100644 --- a/nose2/tests/functional/test_util.py +++ b/nose2/tests/functional/test_util.py @@ -13,7 +13,7 @@ def test_name_from_path(self): def test_non_ascii_output(self): class D: - def __init__(self): + def __init__(self) -> None: self.out = [] def write(self, arg): diff --git a/nose2/tests/unit/test_buffer_plugin.py b/nose2/tests/unit/test_buffer_plugin.py index 21709ec0..a8d432e8 100644 --- a/nose2/tests/unit/test_buffer_plugin.py +++ b/nose2/tests/unit/test_buffer_plugin.py @@ -36,7 +36,7 @@ def test_mixed_unicode_and_nonascii_str(self): self.case = Test class Watcher(events.Plugin): - def __init__(self): + def __init__(self) -> None: self.events = [] def testOutcome(self, event): diff --git a/nose2/tests/unit/test_debugger_plugin.py b/nose2/tests/unit/test_debugger_plugin.py index 578956c1..c412d68e 100644 --- a/nose2/tests/unit/test_debugger_plugin.py +++ b/nose2/tests/unit/test_debugger_plugin.py @@ -11,7 +11,7 @@ def emit(self, record): class StubPdb: - def __init__(self): + def __init__(self) -> None: self.called = False self.tb = None diff --git a/nose2/tests/unit/test_loader.py b/nose2/tests/unit/test_loader.py index e1ed3665..b7af5921 100644 --- a/nose2/tests/unit/test_loader.py +++ b/nose2/tests/unit/test_loader.py @@ -76,7 +76,7 @@ def test_loader_from_names_calls_names_hook(self): class FakePlugin: - def __init__(self): + def __init__(self) -> None: self.fakeLoadFromModule = False self.fakeLoadFromName = False self.fakeLoadFromNames = False diff --git a/nose2/tests/unit/test_logcapture_plugin.py b/nose2/tests/unit/test_logcapture_plugin.py index 56346d18..8daea9d9 100644 --- a/nose2/tests/unit/test_logcapture_plugin.py +++ b/nose2/tests/unit/test_logcapture_plugin.py @@ -8,7 +8,7 @@ class StubLogging: - def __init__(self, name=None): + def __init__(self, name=None) -> None: self.name = name self.handlers = [] self.level = None @@ -29,7 +29,7 @@ def debug(self, message, *arg): class StubRecord: - def __init__(self, message): + def __init__(self, message) -> None: self.message = message self.name = "stub" self.levelname = "stub" diff --git a/nose2/tests/unit/test_outcomes_plugin.py b/nose2/tests/unit/test_outcomes_plugin.py index 21497773..d6bd6295 100644 --- a/nose2/tests/unit/test_outcomes_plugin.py +++ b/nose2/tests/unit/test_outcomes_plugin.py @@ -25,7 +25,7 @@ def test_e3(self): self.case = Test class Watcher(events.Plugin): - def __init__(self): + def __init__(self) -> None: self.outcomes = {} def testOutcome(self, event): diff --git a/nose2/tests/unit/test_printhooks_plugin.py b/nose2/tests/unit/test_printhooks_plugin.py index 5af053a8..130224c2 100644 --- a/nose2/tests/unit/test_printhooks_plugin.py +++ b/nose2/tests/unit/test_printhooks_plugin.py @@ -9,7 +9,7 @@ class CustomEvent(events.Event): _attrs = events.Event._attrs + ("args",) - def __init__(self, args, **kw): + def __init__(self, args, **kw) -> None: self.args = args super().__init__(**kw) diff --git a/nose2/tests/unit/test_testclass_loader.py b/nose2/tests/unit/test_testclass_loader.py index ae1b58d5..328672c3 100644 --- a/nose2/tests/unit/test_testclass_loader.py +++ b/nose2/tests/unit/test_testclass_loader.py @@ -88,7 +88,7 @@ class Mod: self.module = Mod() class TestA: - def __init__(self): + def __init__(self) -> None: raise RuntimeError("Something bad happened!") def test(self): diff --git a/nose2/tools/such.py b/nose2/tools/such.py index 0bbfffad..731a9e94 100644 --- a/nose2/tools/such.py +++ b/nose2/tools/such.py @@ -49,7 +49,7 @@ class Scenario: _helper = helper - def __init__(self, description): + def __init__(self, description) -> None: self._group = Group("A %s" % description, 0) @contextmanager @@ -340,7 +340,7 @@ def tearDown(cls): class Group: """A group of tests, with common fixtures and description""" - def __init__(self, description, indent=0, parent=None, base_layer=None): + def __init__(self, description, indent=0, parent=None, base_layer=None) -> None: self.description = description self.indent = indent self.parent = parent @@ -391,7 +391,7 @@ class Case: _helper = helper - def __init__(self, group, func, description): + def __init__(self, group, func, description) -> None: self.group = group self.func = func self.description = description diff --git a/nose2/util.py b/nose2/util.py index 88af2e6e..e29b2259 100644 --- a/nose2/util.py +++ b/nose2/util.py @@ -330,7 +330,7 @@ def _count_relevant_tb_levels(tb): class _WritelnDecorator: """Used to decorate file-like objects with a handy :func:`writeln` method""" - def __init__(self, stream): + def __init__(self, stream) -> None: self.stream = stream def __getattr__(self, attr): diff --git a/pyproject.toml b/pyproject.toml index a8be6d61..963b8fa1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries",