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

pyta-uoft / pyta / 8849617014

26 Apr 2024 02:11PM UTC coverage: 89.827% (-6.0%) from 95.841%
8849617014

push

github

web-flow
Fixed infinite recursion in representation invariants with method calls (#1031)

15 of 17 new or added lines in 1 file covered. (88.24%)

165 existing lines in 15 files now uncovered.

2746 of 3057 relevant lines covered (89.83%)

8.85 hits per line

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

82.35
/python_ta/__main__.py
1
import os
10✔
2
import sys
10✔
3
from typing import List, Optional
10✔
4

5
import click
10✔
6

7
from python_ta import __version__, check_all, check_errors
10✔
8

9
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
10✔
10

11

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

56
    # `config` is None if `-c` flag is not set
57
    if generate_config:
10✔
UNCOV
58
        pylintrc_location = os.path.join(os.path.dirname(__file__), "config/.pylintrc")
×
UNCOV
59
        with open(pylintrc_location, "r") as f:
×
UNCOV
60
            contents = f.read()
×
UNCOV
61
            print(contents)
×
UNCOV
62
            sys.exit(0)
×
63

64
    checker = check_errors if errors_only else check_all
10✔
65
    paths = [click.format_filename(fn) for fn in filenames]
10✔
66

67
    if config is None:
10✔
UNCOV
68
        reporter = checker(module_name=paths, config={"output-format": output_format})
×
69
    else:
70
        reporter = checker(module_name=paths, config=config)
10✔
71

72
    if not exit_zero and reporter.has_messages():
10✔
73
        sys.exit(1)
10✔
74
    else:
75
        sys.exit(0)
10✔
76

77

78
if __name__ == "__main__":
10✔
79
    main()
10✔
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