Skip to content

Commit

Permalink
add type hints to tasks.py
Browse files Browse the repository at this point in the history
  • Loading branch information
cs01 committed Aug 27, 2019
1 parent 6145f00 commit 0bcedad
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions nox/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
import io
import json
import os
from argparse import Namespace
from typing import List, Union

from colorlog.escape_codes import parse_colors # type: ignore

import nox
from nox import _options, registry
from nox.logger import logger
from nox.manifest import Manifest
from nox.sessions import Result


def load_nox_module(global_config):
Expand Down Expand Up @@ -93,7 +96,9 @@ def discover_manifest(module, global_config):
return Manifest(functions, global_config)


def filter_manifest(manifest, global_config):
def filter_manifest(
manifest: Manifest, global_config: Namespace
) -> Union[Manifest, int]:
"""Filter the manifest according to the provided configuration.
Args:
Expand Down Expand Up @@ -126,7 +131,9 @@ def filter_manifest(manifest, global_config):
return manifest


def honor_list_request(manifest, global_config):
def honor_list_request(
manifest: Manifest, global_config: Namespace
) -> Union[Manifest, int]:
"""If --list was passed, simply list the manifest and exit cleanly.
Args:
Expand Down Expand Up @@ -180,7 +187,9 @@ def honor_list_request(manifest, global_config):
return 0


def verify_manifest_nonempty(manifest, global_config):
def verify_manifest_nonempty(
manifest: Manifest, global_config: Namespace
) -> Union[Manifest, int]:
"""Abort with an error code if the manifest is empty.
Args:
Expand All @@ -196,7 +205,7 @@ def verify_manifest_nonempty(manifest, global_config):
return manifest


def run_manifest(manifest, global_config):
def run_manifest(manifest: Manifest, global_config: Namespace) -> List[Result]:
"""Run the full manifest of sessions.
Args:
Expand Down Expand Up @@ -231,7 +240,7 @@ def run_manifest(manifest, global_config):
return results


def print_summary(results, global_config):
def print_summary(results: List[Result], global_config: Namespace) -> List[Result]:
"""Print a summary of the results.
Args:
Expand Down Expand Up @@ -260,7 +269,7 @@ def print_summary(results, global_config):
return results


def create_report(results, global_config):
def create_report(results: List[Result], global_config: Namespace) -> List[Result]:
"""Write a report to the location designated in the config, if any.
Args:
Expand Down Expand Up @@ -290,7 +299,7 @@ def create_report(results, global_config):
return results


def final_reduce(results, global_config):
def final_reduce(results: List[Result], global_config: Namespace) -> int:
"""Reduce the results to a final exit code.
Args:
Expand Down

0 comments on commit 0bcedad

Please sign in to comment.