Skip to content

Commit

Permalink
Add type hints (finally)
Browse files Browse the repository at this point in the history
  • Loading branch information
econchick committed May 20, 2024
1 parent 182e95a commit da33081
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ jobs:
python -Im pip install --upgrade tox
- name: Run tox targets for ${{ matrix.python-version }}
run: python -Im tox run -f py$(echo ${{ matrix.python-version }} | tr -d .)

- name: Run mypy
run: python -Im tox run -e mypy
if: matrix.python-version == '3.11'

- name: Run mypy
run: python -Im tox run -e mypy
Expand Down
4 changes: 3 additions & 1 deletion src/interrogate/badge_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import os
import sys

from typing import Union

from importlib import resources
from xml.dom import minidom

Expand All @@ -20,7 +22,7 @@
from interrogate.coverage import InterrogateResults


NumberType = int | float
NumberType = Union[int, float]

DEFAULT_FILENAME: str = "interrogate_badge"
COLORS: dict[str, str] = {
Expand Down
6 changes: 3 additions & 3 deletions src/interrogate/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import re
import sys

from typing import List, Optional, Tuple, Union
from typing import List, Optional, Pattern, Tuple, Union

import click
import colorama
Expand Down Expand Up @@ -330,9 +330,9 @@ def main(
ignore_property_decorators: bool,
ignore_setters: bool,
ignore_semiprivate: bool,
ignore_regex: Optional[List[re.Pattern[str]]],
ignore_regex: Optional[List[Pattern[str]]],
ext: Tuple[str],
whitelist_regex: Optional[List[re.Pattern[str]]],
whitelist_regex: Optional[List[Pattern[str]]],
style: str,
output: Optional[str],
color: bool,
Expand Down
3 changes: 2 additions & 1 deletion src/interrogate/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import pathlib
import re

from typing import Any, Sequence
from collections.abc import Sequence
from typing import Any

import attr
import click
Expand Down
8 changes: 5 additions & 3 deletions src/interrogate/visit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
import ast
import os

from typing import Union

import attr

from interrogate.config import InterrogateConfig


DocumentableFunc = ast.AsyncFunctionDef | ast.FunctionDef
DocumentableFuncOrClass = DocumentableFunc | ast.ClassDef
DocumentableNode = DocumentableFuncOrClass | ast.Module
DocumentableFunc = Union[ast.AsyncFunctionDef, ast.FunctionDef]
DocumentableFuncOrClass = Union[DocumentableFunc, ast.ClassDef]
DocumentableNode = Union[DocumentableFuncOrClass, ast.Module]


@attr.s(eq=False)
Expand Down

0 comments on commit da33081

Please sign in to comment.