@@ -96,36 +96,36 @@ def parse_wheel_filename(
96
96
) -> tuple [NormalizedName , Version , BuildTag , frozenset [Tag ]]:
97
97
if not filename .endswith (".whl" ):
98
98
raise InvalidWheelFilename (
99
- f"Invalid wheel filename (extension must be '.whl'): { filename } "
99
+ f"Invalid wheel filename (extension must be '.whl'): { filename !r } "
100
100
)
101
101
102
102
filename = filename [:- 4 ]
103
103
dashes = filename .count ("-" )
104
104
if dashes not in (4 , 5 ):
105
105
raise InvalidWheelFilename (
106
- f"Invalid wheel filename (wrong number of parts): { filename } "
106
+ f"Invalid wheel filename (wrong number of parts): { filename !r } "
107
107
)
108
108
109
109
parts = filename .split ("-" , dashes - 2 )
110
110
name_part = parts [0 ]
111
111
# See PEP 427 for the rules on escaping the project name.
112
112
if "__" in name_part or re .match (r"^[\w\d._]*$" , name_part , re .UNICODE ) is None :
113
- raise InvalidWheelFilename (f"Invalid project name: { filename } " )
113
+ raise InvalidWheelFilename (f"Invalid project name: { filename !r } " )
114
114
name = canonicalize_name (name_part )
115
115
116
116
try :
117
117
version = Version (parts [1 ])
118
118
except InvalidVersion as e :
119
119
raise InvalidWheelFilename (
120
- f"Invalid wheel filename (invalid version): { filename } "
120
+ f"Invalid wheel filename (invalid version): { filename !r } "
121
121
) from e
122
122
123
123
if dashes == 5 :
124
124
build_part = parts [2 ]
125
125
build_match = _build_tag_regex .match (build_part )
126
126
if build_match is None :
127
127
raise InvalidWheelFilename (
128
- f"Invalid build number: { build_part } in '{ filename } '"
128
+ f"Invalid build number: { build_part } in '{ filename !r } '"
129
129
)
130
130
build = cast (BuildTag , (int (build_match .group (1 )), build_match .group (2 )))
131
131
else :
@@ -142,22 +142,22 @@ def parse_sdist_filename(filename: str) -> tuple[NormalizedName, Version]:
142
142
else :
143
143
raise InvalidSdistFilename (
144
144
f"Invalid sdist filename (extension must be '.tar.gz' or '.zip'):"
145
- f" { filename } "
145
+ f" { filename !r } "
146
146
)
147
147
148
148
# We are requiring a PEP 440 version, which cannot contain dashes,
149
149
# so we split on the last dash.
150
150
name_part , sep , version_part = file_stem .rpartition ("-" )
151
151
if not sep :
152
- raise InvalidSdistFilename (f"Invalid sdist filename: { filename } " )
152
+ raise InvalidSdistFilename (f"Invalid sdist filename: { filename !r } " )
153
153
154
154
name = canonicalize_name (name_part )
155
155
156
156
try :
157
157
version = Version (version_part )
158
158
except InvalidVersion as e :
159
159
raise InvalidSdistFilename (
160
- f"Invalid sdist filename (invalid version): { filename } "
160
+ f"Invalid sdist filename (invalid version): { filename !r } "
161
161
) from e
162
162
163
163
return (name , version )
0 commit comments