• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pyta-uoft / pyta / 21228895400

21 Jan 2026 11:03PM UTC coverage: 94.147% (-0.03%) from 94.174%
21228895400

Pull #1287

github

web-flow
Merge 1372345bb into d7d8d91fb
Pull Request #1287: Issue 1284

3555 of 3776 relevant lines covered (94.15%)

17.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.22
/packages/python-ta/src/python_ta/__main__.py
1
from __future__ import annotations
20✔
2

3
import sys
20✔
4
from os import path
20✔
5
from typing import Optional
20✔
6

7
import click
20✔
8

9
from python_ta import __version__, check_all, check_errors
20✔
10
from python_ta.config import DEFAULT_CONFIG_LOCATION
20✔
11

12
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
20✔
13

14

15
@click.command(context_settings=CONTEXT_SETTINGS)
20✔
16
@click.option(
20✔
17
    "-v", "--version", is_flag=True, help="Print current version of PythonTA.", default=False
18
)
19
@click.option(
20✔
20
    "-c",
21
    "--config",
22
    type=click.Path(exists=True, dir_okay=False, resolve_path=True),
23
    help="python_ta configuration file",
24
)
25
@click.option("-E", "--errors-only", is_flag=True, help="Displays errors only", default=False)
20✔
26
@click.argument(
20✔
27
    "filenames", nargs=-1, type=click.Path(exists=True, dir_okay=True, resolve_path=True)
28
)
29
@click.option("--exit-zero", is_flag=True, help="Always return with status code 0", default=False)
20✔
30
@click.option(
20✔
31
    "-g",
32
    "--generate-config",
33
    is_flag=True,
34
    help="Print out default PythonTA configuration file",
35
    default=False,
36
)
37
@click.option(
20✔
38
    "--output-format",
39
    help="Specify the format of output report. This option is ignored if a --config argument is specified.",
40
    default="pyta-html",
41
)
42
def main(
20✔
43
    version: bool,
44
    config: Optional[str],
45
    errors_only: bool,
46
    filenames: list[str],
47
    exit_zero: bool,
48
    generate_config: bool,
49
    output_format: str,
50
) -> None:
51
    """A code checking tool for teaching Python.
52
    FILENAMES can be a string of a directory, or file to check (`.py` extension optional) or
53
    a list of strings of directories or files.
54
    """
55
    if version:
20✔
56
        print(__version__)
20✔
57
        return
20✔
58

59
    # `config` is None if `-c` flag is not set
60
    if generate_config:
20✔
61
        pylintrc_location = path.join(path.dirname(__file__), DEFAULT_CONFIG_LOCATION)
20✔
62
        with open(pylintrc_location, "r") as f:
20✔
63
            contents = f.read()
20✔
64
            print(contents)
20✔
65
            sys.exit(0)
20✔
66

67
    checker = check_errors if errors_only else check_all
20✔
68
    paths = [click.format_filename(fn) for fn in filenames]
20✔
69

70
    if config is None:
20✔
71
        reporter = checker(module_name=paths, config={"output-format": output_format})
20✔
72
    else:
73
        reporter = checker(module_name=paths, config=config)
20✔
74

75
    if not exit_zero and reporter.has_messages():
20✔
76
        sys.exit(1)
20✔
77
    else:
78
        sys.exit(0)
20✔
79

80

81
if __name__ == "__main__":
20✔
82
    main()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc