Skip to content

Commit 50fffb0

Browse files
committed
fix: deprecate coverage3 and coverage-3.10 entry points
1 parent b046636 commit 50fffb0

File tree

5 files changed

+26
-13
lines changed

5 files changed

+26
-13
lines changed

CHANGES.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ upgrading your version of coverage.py.
2323
Unreleased
2424
----------
2525

26-
Nothing yet.
26+
- Deprecated: when coverage.py is installed, it creates three command entry
27+
points: `coverage`, `coverage3`, and `coverage-3.10` (if installed for Python
28+
3.10). The second and third of these are not needed and will eventually be
29+
removed.
2730

2831

2932
.. start-releases

coverage/cmdline.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,20 @@ def main(argv: list[str] | None = None) -> int | None:
11611161
return status
11621162

11631163

1164+
def main_deprecated(argv: list[str] | None = None) -> int | None:
1165+
"""For entry points we'll be getting rid of."""
1166+
print(
1167+
textwrap.dedent("""\
1168+
**
1169+
** This entry point is deprecated and will be removed.
1170+
** Send me an email if you want to keep this command name working:
1171+
1172+
**
1173+
""")
1174+
)
1175+
return main(argv)
1176+
1177+
11641178
# Profiling using ox_profile. Install it from GitHub:
11651179
# pip install git+https://github.com/emin63/ox_profile.git
11661180
#

doc/commands/index.rst

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,8 @@ Commands
99

1010
.. highlight:: console
1111

12-
When you install coverage.py, a command-line script called ``coverage`` is
13-
placed on your path. To help with multi-version installs, it will also create
14-
a ``coverage3`` alias, and a ``coverage-X.Y`` alias, depending on the version
15-
of Python you're using. For example, when installing on Python 3.10, you will
16-
be able to use ``coverage``, ``coverage3``, or ``coverage-3.10`` on the command
17-
line.
18-
19-
Coverage.py has a number of commands:
12+
When you install coverage.py, a command called ``coverage`` is installed for
13+
command-line use. It has a number of commands:
2014

2115
* **run** -- :ref:`Run a Python program and collect execution data <cmd_run>`.
2216

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ def do_make_pth():
116116
for sp in site.getsitepackages()
117117
],
118118
entry_points={
119-
# Install a script as "coverage", and as "coverage3", and as
120-
# "coverage-3.7" (or whatever).
121119
"console_scripts": [
120+
# Install a script as "coverage".
122121
"coverage = coverage.cmdline:main",
123-
"coverage%d = coverage.cmdline:main" % sys.version_info[:1],
124-
"coverage-%d.%d = coverage.cmdline:main" % sys.version_info[:2],
122+
# And as "coverage3", and as "coverage-3.7" (or whatever), but deprecated.
123+
"coverage%d = coverage.cmdline:main_deprecated" % sys.version_info[:1],
124+
"coverage-%d.%d = coverage.cmdline:main_deprecated" % sys.version_info[:2],
125125
],
126126
},
127127
extras_require={

tests/test_process.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,7 @@ def test_major_version_works(self) -> None:
12061206
# "coverage3" works on py3
12071207
cmd = "coverage%d" % sys.version_info[0]
12081208
out = self.run_command(cmd)
1209+
assert "deprecated" in out
12091210
assert "Code coverage for Python" in out
12101211

12111212
def test_wrong_alias_doesnt_work(self) -> None:
@@ -1220,6 +1221,7 @@ def test_specific_alias_works(self) -> None:
12201221
# "coverage-3.9" works on py3.9
12211222
cmd = "coverage-%d.%d" % sys.version_info[:2]
12221223
out = self.run_command(cmd)
1224+
assert "deprecated" in out
12231225
assert "Code coverage for Python" in out
12241226

12251227
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)