Skip to content

Commit

Permalink
chore: add some missing type hints
Browse files Browse the repository at this point in the history
- the tests are passing
  • Loading branch information
mattcristal authored and auvipy committed Jun 10, 2023
1 parent 977746b commit ef58b05
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pytest_sugar.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import sys
import time
from configparser import ConfigParser # type: ignore
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
from typing import Any, Dict, Generator, List, Optional, Sequence, Tuple, Union

import pytest
from _pytest.config.argparsing import Parser
Expand Down Expand Up @@ -84,7 +84,7 @@ def __getitem__(self, x):
]


def flatten(seq):
def flatten(seq) -> Generator[Any, None, None]:
for x in seq:
if isinstance(x, (list, tuple)):
yield from flatten(x)
Expand All @@ -99,7 +99,7 @@ def pytest_collection_finish(session: Session) -> None:


class DeferredXdistPlugin:
def pytest_xdist_node_collection_finished(self, node, ids):
def pytest_xdist_node_collection_finished(self, node, ids) -> None:
terminal_reporter = node.config.pluginmanager.getplugin("terminalreporter")
if terminal_reporter:
terminal_reporter.tests_count = len(ids)
Expand Down Expand Up @@ -175,7 +175,7 @@ def real_string_length(string: str) -> int:


@pytest.hookimpl(trylast=True)
def pytest_configure(config):
def pytest_configure(config) -> None:
global IS_SUGAR_ENABLED

if sys.stdout.isatty() or config.getvalue("force_sugar"):
Expand Down Expand Up @@ -236,7 +236,7 @@ def pytest_report_teststatus(report: BaseReport) -> Optional[Tuple[str, str, str


class SugarTerminalReporter(TerminalReporter): # type: ignore
def __init__(self, reporter):
def __init__(self, reporter) -> None:
TerminalReporter.__init__(self, reporter.config)
self.paths_left = []
self.tests_count = 0
Expand All @@ -246,7 +246,7 @@ def __init__(self, reporter):
self.progress_blocks = []
self.reset_tracked_lines()

def reset_tracked_lines(self):
def reset_tracked_lines(self) -> None:
self.current_lines = {}
self.current_line_nums = {}
self.current_line_num = 0
Expand Down Expand Up @@ -287,7 +287,7 @@ def write_fspath_result(self, nodeid: str, res, **markup: bool) -> None:
return

def insert_progress(self, report: Union[CollectReport, TestReport]) -> None:
def get_progress_bar():
def get_progress_bar() -> str:
length = LEN_PROGRESS_BAR
if not length:
return ""
Expand Down

0 comments on commit ef58b05

Please sign in to comment.