Skip to content

Commit

Permalink
fix: export our public names for type checking. #1564
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Feb 26, 2023
1 parent f217d0d commit c3a3421
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ Unreleased
- Fix: the PyPI page had broken links to documentation pages, but no longer
does, closing `issue 1566`_.

- Fix: public members of the coverage module are now properly indicated so that
mypy will find them, fixing `issue 1564`_.

.. _issue 1564: https://github.com/nedbat/coveragepy/issues/1564
.. _issue 1566: https://github.com/nedbat/coveragepy/issues/1566


Expand Down
28 changes: 21 additions & 7 deletions coverage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,29 @@
"""

import sys
# mypy's convention is that "import as" names are public from the module.
# We import names as themselves to indicate that. Pylint sees it as pointless,
# so disable its warning.
# pylint: disable=useless-import-alias

from coverage.version import __version__, __url__, version_info
import sys

from coverage.control import Coverage, process_startup
from coverage.data import CoverageData
from coverage.exceptions import CoverageException
from coverage.plugin import CoveragePlugin, FileTracer, FileReporter
from coverage.pytracer import PyTracer
from coverage.version import (
__version__ as __version__,
version_info as version_info,
)

from coverage.control import (
Coverage as Coverage,
process_startup as process_startup,
)
from coverage.data import CoverageData as CoverageData
from coverage.exceptions import CoverageException as CoverageException
from coverage.plugin import (
CoveragePlugin as CoveragePlugin,
FileReporter as FileReporter,
FileTracer as FileTracer,
)

# Backward compatibility.
coverage = Coverage
Expand Down
2 changes: 2 additions & 0 deletions coverage/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from coverage.exceptions import _BaseCoverageException, _ExceptionDuringRun, NoSource
from coverage.execfile import PyRunner
from coverage.results import Numbers, should_fail_under
from coverage.version import __url__

# When adding to this file, alphabetization is important. Look for
# "alphabetize" comments throughout.
Expand Down Expand Up @@ -574,6 +575,7 @@ def show_help(
program_name = program_name[:-len(auto_suffix)]

help_params = dict(coverage.__dict__)
help_params["__url__"] = __url__
help_params['program_name'] = program_name
if HAS_CTRACER:
help_params['extension_modifier'] = 'with C extension'
Expand Down
3 changes: 2 additions & 1 deletion coverage/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from coverage.results import Analysis, Numbers
from coverage.templite import Templite
from coverage.types import TLineNo, TMorf
from coverage.version import __url__


if TYPE_CHECKING:
Expand Down Expand Up @@ -238,7 +239,7 @@ def __init__(self, cov: Coverage) -> None:
'len': len,

# Constants for this report.
'__url__': coverage.__url__,
'__url__': __url__,
'__version__': coverage.__version__,
'title': title,
'time_stamp': format_local_datetime(datetime.datetime.now()),
Expand Down
3 changes: 2 additions & 1 deletion coverage/xmlreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
from dataclasses import dataclass
from typing import Any, Dict, IO, Iterable, Optional, TYPE_CHECKING, cast

from coverage import __url__, __version__, files
from coverage import __version__, files
from coverage.misc import isolate_module, human_sorted, human_sorted_items
from coverage.plugin import FileReporter
from coverage.report import get_analysis_to_report
from coverage.results import Analysis
from coverage.types import TMorf
from coverage.version import __url__

if TYPE_CHECKING:
from coverage import Coverage
Expand Down

0 comments on commit c3a3421

Please sign in to comment.