Skip to content

Commit 28e15c2

Browse files
authored
fix(coverage): bump to latest coverage.py and fix import shadowing (bazel-contrib#1249)
Fixes bazel-contrib#1196. Currently the `coverage.py` module does not work if updated to the latest version with the following error: ``` ImportError: cannot import name 'MappingProxyType' from partially initialized module 'types' (most likely due to a circular import) ...~pypi__coverage_cp39_x86_64-unknown-linux-gnu/coverage/types.py) ``` Where the `MappingProxyType` actually exists in Python's std lib. To fix, modify sys.path before the first import of coverage. Summary: - chore(coverage): bump coverage.py to 7.2.7 - fix(coverage): patch sys.path before importing anything from coverage - test(coverage): add extra assertions about the module names
1 parent 3912266 commit 28e15c2

File tree

4 files changed

+61
-42
lines changed

4 files changed

+61
-42
lines changed

MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use_repo(
3434
"pypi__coverage_cp310_aarch64-unknown-linux-gnu",
3535
"pypi__coverage_cp310_x86_64-apple-darwin",
3636
"pypi__coverage_cp310_x86_64-unknown-linux-gnu",
37+
"pypi__coverage_cp311_aarch64-apple-darwin",
3738
"pypi__coverage_cp311_aarch64-unknown-linux-gnu",
3839
"pypi__coverage_cp311_x86_64-apple-darwin",
3940
"pypi__coverage_cp311_x86_64-unknown-linux-gnu",

examples/bzlmod/test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ def test_coverage_doesnt_shadow_stdlib(self):
3030
except ImportError:
3131
self.skipTest("not running under coverage, skipping")
3232

33+
self.assertEqual(
34+
"html",
35+
f"{html_stdlib.__name__}",
36+
"'html' from stdlib was not loaded correctly",
37+
)
38+
39+
self.assertEqual(
40+
"coverage.html",
41+
f"{html_coverage.__name__}",
42+
"'coverage.html' was not loaded correctly",
43+
)
44+
3345
self.assertNotEqual(
3446
html_stdlib,
3547
html_coverage,

python/private/coverage.patch

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
# Because of how coverage is run, the current directory is the first in
22
# sys.path. This is a problem for the tests, because they may import a module of
33
# the same name as a module in the current directory.
4-
diff --git a/coverage/cmdline.py b/coverage/cmdline.py
5-
index dbf66e0a..780505ac 100644
6-
--- a/coverage/cmdline.py
7-
+++ b/coverage/cmdline.py
8-
@@ -937,6 +937,7 @@ def main(argv=None):
9-
This is installed as the script entry point.
10-
11-
"""
12-
+ sys.path.append(sys.path.pop(0))
13-
if argv is None:
14-
argv = sys.argv[1:]
15-
try:
4+
#
5+
# NOTE @aignas 2023-06-05: we have to do this before anything from coverage gets
6+
# imported.
7+
diff --git a/coverage/__main__.py b/coverage/__main__.py
8+
index 79aa4e2b..291fcff8 100644
9+
--- a/coverage/__main__.py
10+
+++ b/coverage/__main__.py
11+
@@ -4,5 +4,6 @@
12+
"""Coverage.py's main entry point."""
13+
14+
import sys
15+
+sys.path.append(sys.path.pop(0))
16+
from coverage.cmdline import main
17+
sys.exit(main())

python/private/coverage_deps.bzl

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,70 +28,74 @@ load(
2828
_coverage_deps = {
2929
"cp310": {
3030
"aarch64-apple-darwin": (
31-
"https://files.pythonhosted.org/packages/89/a2/cbf599e50bb4be416e0408c4cf523c354c51d7da39935461a9687e039481/coverage-6.5.0-cp310-cp310-macosx_11_0_arm64.whl",
32-
"784f53ebc9f3fd0e2a3f6a78b2be1bd1f5575d7863e10c6e12504f240fd06660",
31+
"https://files.pythonhosted.org/packages/3d/80/7060a445e1d2c9744b683dc935248613355657809d6c6b2716cdf4ca4766/coverage-7.2.7-cp310-cp310-macosx_11_0_arm64.whl",
32+
"6d040ef7c9859bb11dfeb056ff5b3872436e3b5e401817d87a31e1750b9ae2fb",
3333
),
3434
"aarch64-unknown-linux-gnu": (
35-
"https://files.pythonhosted.org/packages/15/b0/3639d84ee8a900da0cf6450ab46e22517e4688b6cec0ba8ab6f8166103a2/coverage-6.5.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
36-
"b4a5be1748d538a710f87542f22c2cad22f80545a847ad91ce45e77417293eb4",
35+
"https://files.pythonhosted.org/packages/b8/9d/926fce7e03dbfc653104c2d981c0fa71f0572a9ebd344d24c573bd6f7c4f/coverage-7.2.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
36+
"ba90a9563ba44a72fda2e85302c3abc71c5589cea608ca16c22b9804262aaeb6",
3737
),
3838
"x86_64-apple-darwin": (
39-
"https://files.pythonhosted.org/packages/c4/8d/5ec7d08f4601d2d792563fe31db5e9322c306848fec1e65ec8885927f739/coverage-6.5.0-cp310-cp310-macosx_10_9_x86_64.whl",
40-
"ef8674b0ee8cc11e2d574e3e2998aea5df5ab242e012286824ea3c6970580e53",
39+
"https://files.pythonhosted.org/packages/01/24/be01e62a7bce89bcffe04729c540382caa5a06bee45ae42136c93e2499f5/coverage-7.2.7-cp310-cp310-macosx_10_9_x86_64.whl",
40+
"d39b5b4f2a66ccae8b7263ac3c8170994b65266797fb96cbbfd3fb5b23921db8",
4141
),
4242
"x86_64-unknown-linux-gnu": (
43-
"https://files.pythonhosted.org/packages/3c/7d/d5211ea782b193ab8064b06dc0cc042cf1a4ca9c93a530071459172c550f/coverage-6.5.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
44-
"af4fffaffc4067232253715065e30c5a7ec6faac36f8fc8d6f64263b15f74db0",
43+
"https://files.pythonhosted.org/packages/b4/bd/1b2331e3a04f4cc9b7b332b1dd0f3a1261dfc4114f8479bebfcc2afee9e8/coverage-7.2.7-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
44+
"31563e97dae5598556600466ad9beea39fb04e0229e61c12eaa206e0aa202063",
4545
),
4646
},
4747
"cp311": {
48+
"aarch64-apple-darwin": (
49+
"https://files.pythonhosted.org/packages/67/d7/cd8fe689b5743fffac516597a1222834c42b80686b99f5b44ef43ccc2a43/coverage-7.2.7-cp311-cp311-macosx_11_0_arm64.whl",
50+
"5baa06420f837184130752b7c5ea0808762083bf3487b5038d68b012e5937dbe",
51+
),
4852
"aarch64-unknown-linux-gnu": (
49-
"https://files.pythonhosted.org/packages/36/f3/5cbd79cf4cd059c80b59104aca33b8d05af4ad5bf5b1547645ecee716378/coverage-6.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
50-
"c4ed2820d919351f4167e52425e096af41bfabacb1857186c1ea32ff9983ed75",
53+
"https://files.pythonhosted.org/packages/8c/95/16eed713202406ca0a37f8ac259bbf144c9d24f9b8097a8e6ead61da2dbb/coverage-7.2.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
54+
"fdec9e8cbf13a5bf63290fc6013d216a4c7232efb51548594ca3631a7f13c3a3",
5155
),
5256
"x86_64-apple-darwin": (
53-
"https://files.pythonhosted.org/packages/50/cf/455930004231fa87efe8be06d13512f34e070ddfee8b8bf5a050cdc47ab3/coverage-6.5.0-cp311-cp311-macosx_10_9_x86_64.whl",
54-
"4a5375e28c5191ac38cca59b38edd33ef4cc914732c916f2929029b4bfb50795",
57+
"https://files.pythonhosted.org/packages/c6/fa/529f55c9a1029c840bcc9109d5a15ff00478b7ff550a1ae361f8745f8ad5/coverage-7.2.7-cp311-cp311-macosx_10_9_x86_64.whl",
58+
"06a9a2be0b5b576c3f18f1a241f0473575c4a26021b52b2a85263a00f034d51f",
5559
),
5660
"x86_64-unknown-linux-gnu": (
57-
"https://files.pythonhosted.org/packages/6a/63/8e82513b7e4a1b8d887b4e85c1c2b6c9b754a581b187c0b084f3330ac479/coverage-6.5.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
58-
"a8fb6cf131ac4070c9c5a3e21de0f7dc5a0fbe8bc77c9456ced896c12fcdad91",
61+
"https://files.pythonhosted.org/packages/a7/cd/3ce94ad9d407a052dc2a74fbeb1c7947f442155b28264eb467ee78dea812/coverage-7.2.7-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
62+
"63426706118b7f5cf6bb6c895dc215d8a418d5952544042c8a2d9fe87fcf09cb",
5963
),
6064
},
6165
"cp38": {
6266
"aarch64-apple-darwin": (
63-
"https://files.pythonhosted.org/packages/07/82/79fa21ceca9a9b091eb3c67e27eb648dade27b2c9e1eb23af47232a2a365/coverage-6.5.0-cp38-cp38-macosx_11_0_arm64.whl",
64-
"2198ea6fc548de52adc826f62cb18554caedfb1d26548c1b7c88d8f7faa8f6ba",
67+
"https://files.pythonhosted.org/packages/28/d7/9a8de57d87f4bbc6f9a6a5ded1eaac88a89bf71369bb935dac3c0cf2893e/coverage-7.2.7-cp38-cp38-macosx_11_0_arm64.whl",
68+
"3d376df58cc111dc8e21e3b6e24606b5bb5dee6024f46a5abca99124b2229ef5",
6569
),
6670
"aarch64-unknown-linux-gnu": (
67-
"https://files.pythonhosted.org/packages/40/3b/cd68cb278c4966df00158811ec1e357b9a7d132790c240fc65da57e10013/coverage-6.5.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
68-
"6c4459b3de97b75e3bd6b7d4b7f0db13f17f504f3d13e2a7c623786289dd670e",
71+
"https://files.pythonhosted.org/packages/c8/e4/e6182e4697665fb594a7f4e4f27cb3a4dd00c2e3d35c5c706765de8c7866/coverage-7.2.7-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
72+
"5e330fc79bd7207e46c7d7fd2bb4af2963f5f635703925543a70b99574b0fea9",
6973
),
7074
"x86_64-apple-darwin": (
71-
"https://files.pythonhosted.org/packages/05/63/a789b462075395d34f8152229dccf92b25ca73eac05b3f6cd75fa5017095/coverage-6.5.0-cp38-cp38-macosx_10_9_x86_64.whl",
72-
"d900bb429fdfd7f511f868cedd03a6bbb142f3f9118c09b99ef8dc9bf9643c3c",
75+
"https://files.pythonhosted.org/packages/c6/fc/be19131010930a6cf271da48202c8cc1d3f971f68c02fb2d3a78247f43dc/coverage-7.2.7-cp38-cp38-macosx_10_9_x86_64.whl",
76+
"54b896376ab563bd38453cecb813c295cf347cf5906e8b41d340b0321a5433e5",
7377
),
7478
"x86_64-unknown-linux-gnu": (
75-
"https://files.pythonhosted.org/packages/bd/a0/e263b115808226fdb2658f1887808c06ac3f1b579ef5dda02309e0d54459/coverage-6.5.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
76-
"6b07130585d54fe8dff3d97b93b0e20290de974dc8177c320aeaf23459219c0b",
79+
"https://files.pythonhosted.org/packages/44/55/49f65ccdd4dfd6d5528e966b28c37caec64170c725af32ab312889d2f857/coverage-7.2.7-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
80+
"8d13c64ee2d33eccf7437961b6ea7ad8673e2be040b4f7fd4fd4d4d28d9ccb1e",
7781
),
7882
},
7983
"cp39": {
8084
"aarch64-apple-darwin": (
81-
"https://files.pythonhosted.org/packages/63/e9/f23e8664ec4032d7802a1cf920853196bcbdce7b56408e3efe1b2da08f3c/coverage-6.5.0-cp39-cp39-macosx_11_0_arm64.whl",
82-
"95203854f974e07af96358c0b261f1048d8e1083f2de9b1c565e1be4a3a48cfc",
85+
"https://files.pythonhosted.org/packages/ca/0c/3dfeeb1006c44b911ee0ed915350db30325d01808525ae7cc8d57643a2ce/coverage-7.2.7-cp39-cp39-macosx_11_0_arm64.whl",
86+
"06fb182e69f33f6cd1d39a6c597294cff3143554b64b9825d1dc69d18cc2fff2",
8387
),
8488
"aarch64-unknown-linux-gnu": (
85-
"https://files.pythonhosted.org/packages/18/95/27f80dcd8273171b781a19d109aeaed7f13d78ef6d1e2f7134a5826fd1b4/coverage-6.5.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
86-
"b9023e237f4c02ff739581ef35969c3739445fb059b060ca51771e69101efffe",
89+
"https://files.pythonhosted.org/packages/61/af/5964b8d7d9a5c767785644d9a5a63cacba9a9c45cc42ba06d25895ec87be/coverage-7.2.7-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
90+
"201e7389591af40950a6480bd9edfa8ed04346ff80002cec1a66cac4549c1ad7",
8791
),
8892
"x86_64-apple-darwin": (
89-
"https://files.pythonhosted.org/packages/ea/52/c08080405329326a7ff16c0dfdb4feefaa8edd7446413df67386fe1bbfe0/coverage-6.5.0-cp39-cp39-macosx_10_9_x86_64.whl",
90-
"633713d70ad6bfc49b34ead4060531658dc6dfc9b3eb7d8a716d5873377ab745",
93+
"https://files.pythonhosted.org/packages/88/da/495944ebf0ad246235a6bd523810d9f81981f9b81c6059ba1f56e943abe0/coverage-7.2.7-cp39-cp39-macosx_10_9_x86_64.whl",
94+
"537891ae8ce59ef63d0123f7ac9e2ae0fc8b72c7ccbe5296fec45fd68967b6c9",
9195
),
9296
"x86_64-unknown-linux-gnu": (
93-
"https://files.pythonhosted.org/packages/6b/f2/919f0fdc93d3991ca074894402074d847be8ac1e1d78e7e9e1c371b69a6f/coverage-6.5.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
94-
"8f830ed581b45b82451a40faabb89c84e1a998124ee4212d440e9c6cf70083e5",
97+
"https://files.pythonhosted.org/packages/fe/57/e4f8ad64d84ca9e759d783a052795f62a9f9111585e46068845b1cb52c2b/coverage-7.2.7-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
98+
"6f48351d66575f535669306aa7d6d6f71bc43372473b54a832222803eb956fd1",
9599
),
96100
},
97101
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy