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

unipoll / api / 7137855324

08 Dec 2023 05:40AM UTC coverage: 82.308% (+2.2%) from 80.101%
7137855324

push

github

mike-pisman
chore: Fixed mypy linting

3 of 3 new or added lines in 1 file covered. (100.0%)

185 existing lines in 16 files now uncovered.

1954 of 2374 relevant lines covered (82.31%)

0.82 hits per line

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

27.27
/src/unipoll_api/utils/cli_args.py
1
import argparse
1✔
2
import textwrap
1✔
3
from unipoll_api.config import get_settings
1✔
4

5
settings = get_settings()
1✔
6

7

8
# Check if IP address is valid
9
def check_ip(arg_value):
1✔
UNCOV
10
    address = arg_value.split(".")
×
UNCOV
11
    if len(address) != 4:
×
UNCOV
12
        raise argparse.ArgumentTypeError("invalid host value")
×
UNCOV
13
    for i in address:
×
UNCOV
14
        if int(i) > 255 or int(i) < 0:
×
15
            raise argparse.ArgumentTypeError("invalid host value")
×
16
    return arg_value
×
17

18

19
# Parse CLI arguments
20
def parse_args():
1✔
21
    parser = argparse.ArgumentParser(description="University Polling API")
×
UNCOV
22
    subparser = parser.add_subparsers(title='Available commands', dest='command', required=True)
×
23

UNCOV
24
    run_parser = subparser.add_parser('run',
×
25
                                      help="Run the API server",
26
                                      formatter_class=argparse.RawDescriptionHelpFormatter,
27
                                      description=textwrap.dedent('''\
28
        Run University Polling API
29
        --------------------------------
30
        Examples:
31

32
            python main.py --reload --host=127.0.0.1 --port=8000
33
            python main.py --reload
34
        '''))
35

UNCOV
36
    run_parser.add_argument("--reload", action="store_true", help="Enable auto-reload", default=False)
×
UNCOV
37
    run_parser.add_argument("--host", type=check_ip, default=settings.host, help="Host IP address")
×
38
    run_parser.add_argument("--port", type=int, default=settings.port, help="Host port number")
×
39

40
    subparser.add_parser('setup', help="Setup the API server")
×
41
    subparser.add_parser('get-openapi', help="Get the OpenAPI schema")
×
42

43
    return parser.parse_args()
×
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