Skip to content

Commit bf31995

Browse files
committed
Fix platform exclude regex.
1 parent 175e411 commit bf31995

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

coverage_pyver_pragma/__init__.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import platform
2929
import re
3030
import sys
31-
from typing import TYPE_CHECKING, Any, List, NamedTuple, Pattern, Union
31+
from typing import TYPE_CHECKING, Any, List, NamedTuple, Pattern, Tuple, Union
3232

3333
# 3rd party
3434
import coverage # type: ignore
@@ -60,13 +60,13 @@ class Version(NamedTuple):
6060

6161
major: int
6262
minor: int
63-
micro: int
64-
releaselevel: str
65-
serial: str
63+
micro: int = 0
64+
releaselevel: str = ''
65+
serial: str = ''
6666

6767

6868
def make_regexes(
69-
version_tuple: Union["Version", "VersionInfo"],
69+
version_tuple: Union["Version", "VersionInfo", Tuple[int, ...]],
7070
current_platform: str,
7171
current_implementation: str,
7272
) -> List[Pattern]:
@@ -82,6 +82,9 @@ def make_regexes(
8282
8383
:return: List of regular expressions.
8484
"""
85+
86+
version_tuple = Version(*version_tuple)
87+
8588
if version_tuple.major == 3:
8689
# Python 3.X
8790

@@ -117,7 +120,9 @@ def make_regexes(
117120
re.compile(
118121
fr"{regex_main}\s*\((?=\s*(py|PY|Py)3({'|'.join(exact_versions)})){wrong_platforms_string}{wrong_implementations_string}.*\)"
119122
),
120-
re.compile(fr"{regex_main}\s*\({wrong_platforms_string}{wrong_implementations_string}.*\)"),
123+
re.compile(
124+
fr"{regex_main}\s*\((?!.*(py|PY|Py)[0-9]+){wrong_platforms_string}{wrong_implementations_string}.*\)"
125+
),
121126
]
122127

123128
# print(excludes)

0 commit comments

Comments
 (0)