99import textwrap
1010import zipfile
1111from pathlib import Path
12+ from typing import ClassVar
1213from unittest .mock import patch
1314
1415import pytest
4344class TestTranslateExtension :
4445 def test_no_change_on_native (self ):
4546 """No translation when extension is already native."""
46- if sys .platform == "linux" :
47- assert translate_extension ("foo.so" ) == "foo.so"
48- elif sys .platform == "darwin" :
47+ if sys .platform in ("linux" , "darwin" ):
4948 assert translate_extension ("foo.so" ) == "foo.so"
5049 elif sys .platform == "win32" :
5150 assert translate_extension ("foo.pyd" ) == "foo.pyd"
@@ -129,7 +128,7 @@ def test_nested_directory_pattern(self):
129128
130129
131130class TestCheckPresent :
132- FILES = [
131+ FILES : ClassVar [ list [ str ]] = [
133132 "check_dist/__init__.py" ,
134133 "check_dist/_core.py" ,
135134 "LICENSE" ,
@@ -170,7 +169,7 @@ def test_cross_platform_missing(self, _mock):
170169
171170
172171class TestCheckAbsent :
173- FILES = [
172+ FILES : ClassVar [ list [ str ]] = [
174173 "check_dist/__init__.py" ,
175174 "Makefile" ,
176175 ".github/workflows/ci.yml" ,
@@ -357,7 +356,7 @@ class TestSdistExpectedFiles:
357356 """Covers hatch semantics: packages, include, exclude, only-include,
358357 force-include, sources, and their interactions."""
359358
360- VCS = [
359+ VCS : ClassVar [ list [ str ]] = [
361360 "pkg/__init__.py" ,
362361 "pkg/core.py" ,
363362 "rust/src/lib.rs" ,
@@ -534,7 +533,7 @@ def test_empty_config(self):
534533class TestFilterExtrasByHatch :
535534 """Verify that copier-derived extras are trimmed to match hatch config."""
536535
537- EXTRAS = ["rust" , "src" , "Cargo.toml" , "Cargo.lock" , "target" ]
536+ EXTRAS : ClassVar [ list [ str ]] = ["rust" , "src" , "Cargo.toml" , "Cargo.lock" , "target" ]
538537
539538 def test_no_hatch_config (self ):
540539 assert _filter_extras_by_hatch (self .EXTRAS , {}) == self .EXTRAS
@@ -940,8 +939,8 @@ class TestGetVcsFiles:
940939 def test_in_git_repo (self , tmp_path ):
941940 """Integration test: create a real tiny git repo."""
942941 subprocess .run (["git" , "init" , str (tmp_path )], capture_output = True , check = True )
943- subprocess .run (["git" , "config" , "user.email" , "test@test.com" ], cwd = str (tmp_path ), capture_output = True )
944- subprocess .run (["git" , "config" , "user.name" , "Test" ], cwd = str (tmp_path ), capture_output = True )
942+ subprocess .run (["git" , "config" , "user.email" , "test@test.com" ], cwd = str (tmp_path ), capture_output = True , check = False )
943+ subprocess .run (["git" , "config" , "user.name" , "Test" ], cwd = str (tmp_path ), capture_output = True , check = False )
945944 (tmp_path / "hello.py" ).write_text ("print('hi')\n " )
946945 subprocess .run (["git" , "add" , "hello.py" ], cwd = str (tmp_path ), capture_output = True , check = True )
947946 subprocess .run (["git" , "commit" , "-m" , "init" ], cwd = str (tmp_path ), capture_output = True , check = True )
@@ -992,8 +991,8 @@ def _make_project(tmp_path: Path, *, extra_files: dict[str, str] | None = None)
992991
993992 # Set up a git repo so VCS checks work
994993 subprocess .run (["git" , "init" , str (proj )], capture_output = True , check = True )
995- subprocess .run (["git" , "config" , "user.email" , "t@t.com" ], cwd = str (proj ), capture_output = True )
996- subprocess .run (["git" , "config" , "user.name" , "T" ], cwd = str (proj ), capture_output = True )
994+ subprocess .run (["git" , "config" , "user.email" , "t@t.com" ], cwd = str (proj ), capture_output = True , check = False )
995+ subprocess .run (["git" , "config" , "user.name" , "T" ], cwd = str (proj ), capture_output = True , check = False )
997996 subprocess .run (["git" , "add" , "." ], cwd = str (proj ), capture_output = True , check = True )
998997 subprocess .run (["git" , "commit" , "-m" , "init" ], cwd = str (proj ), capture_output = True , check = True )
999998 return proj
@@ -1027,7 +1026,7 @@ def test_missing_present_pattern(self, tmp_path):
10271026 @pytest .mark .slow
10281027 def test_verbose_lists_files (self , tmp_path ):
10291028 proj = _make_project (tmp_path )
1030- success , messages = check_dist (str (proj ), verbose = True )
1029+ _success , messages = check_dist (str (proj ), verbose = True )
10311030 combined = "\n " .join (messages )
10321031 # Verbose mode should list individual files
10331032 assert "mypkg/__init__.py" in combined
@@ -1039,6 +1038,7 @@ def test_help(self):
10391038 [sys .executable , "-m" , "check_dist._cli" , "--help" ],
10401039 capture_output = True ,
10411040 text = True ,
1041+ check = False ,
10421042 )
10431043 assert result .returncode == 0
10441044 assert "check-dist" in result .stdout .lower () or "Check Python" in result .stdout
0 commit comments