diff --git a/template/pyproject.toml.jinja b/template/pyproject.toml.jinja index ce94eda..156e2ec 100644 --- a/template/pyproject.toml.jinja +++ b/template/pyproject.toml.jinja @@ -29,7 +29,7 @@ lockfile = { shell = "python3 scripts/pdm_lockfile.py" } "lint:pycodestyle" = { shell = "pycodestyle --ignore E501,W503,E261 {{ module_name }}" } "lint:pydocstyle" = { shell = "pydocstyle {{ module_name }}" } "lint:bandit" = { shell = "bandit -s B101 -r {{ module_name }}" } -"lint:vulture" = { shell = "vulture {{ module_name }}" } +"lint:vulture" = { shell = "vulture --ignore-names model_config,comet_enabled,comet_api_key,comet_project_name,comet_workspace,create_experiment {{ module_name }}" } "lint:isort" = { shell = "isort -c {{ module_name }}" } lint = { composite = [ "lint:mypy", diff --git a/template/{{ module_name }}/utils/{% if use_comet %}comet.py{% endif %}.jinja b/template/{{ module_name }}/utils/{% if use_comet %}comet.py{% endif %}.jinja index 7963e46..c251c1f 100644 --- a/template/{{ module_name }}/utils/{% if use_comet %}comet.py{% endif %}.jinja +++ b/template/{{ module_name }}/utils/{% if use_comet %}comet.py{% endif %}.jinja @@ -3,14 +3,15 @@ from typing import Optional -from comet_ml import Experiment +# pycodestyle: disable=E621 +from comet_ml import Experiment # type: ignore from ..settings import Settings def create_experiment(settings: Settings) -> Optional[Experiment]: """Create a Comet experiment. - + Arguments ========= settings: Settings diff --git a/tests/test_copy.py b/tests/test_copy.py index 7c40f1f..9398049 100644 --- a/tests/test_copy.py +++ b/tests/test_copy.py @@ -59,7 +59,7 @@ def _create_data_base( def _create_data_minimal(license: str, python_version: str) -> Dict[str, str]: - base = _create_data_base(license, python_version, "not_applicable") + base = _create_data_base(license, python_version, "default") base["use_pytorch"] = "false" base["use_tensorflow"] = "false" @@ -189,7 +189,7 @@ def _create_directory_test_minimal(license: str, cuda_version: str) -> Directory ] ), ".pdm-python": FileTest(), - f"pdm.{sys.platform}.{('default' if cuda_version == 'not_applicable' else cuda_version)}.lock": FileTest(), + f"pdm.{sys.platform}.{('default' if cuda_version == 'default' else cuda_version)}.lock": FileTest(), "pdm.lock": FileTest(), "pyproject.toml": FileTest( on_text=[ @@ -221,7 +221,21 @@ def _create_directory_test_minimal(license: str, cuda_version: str) -> Directory "__pypackages__": DirectoryTest(ignore_children=True, optional=True), "language_model": DirectoryTest( child_files={ - "__init__.py": FileTest(on_text=[_test_file_empty]), + "__init__.py": FileTest( + on_text=[ + lambda text: _test_file_starts_with_license_hashes( + license != "none", text + ), + lambda text: _test_file_license_content(license, text), + lambda text: _test_file_two_newlines_after_license_hashes( + license != "none", text + ), + _test_file_python_version_with_dot, + ], + on_path=[ + _test_file_formatting_black, + ], + ), "settings.py": FileTest( on_text=[ lambda text: _test_file_starts_with_license_hashes( @@ -340,7 +354,23 @@ def _create_directory_test_minimal(license: str, cuda_version: str) -> Directory _test_file_formatting_black, ], ), - "__init__.py": FileTest(on_text=[_test_file_empty]), + "__init__.py": FileTest( + on_text=[ + lambda text: _test_file_starts_with_license_hashes( + license != "none", text + ), + lambda text: _test_file_license_content( + license, text + ), + lambda text: _test_file_two_newlines_after_license_hashes( + license != "none", text + ), + _test_file_python_version_with_dot, + ], + on_path=[ + _test_file_formatting_black, + ], + ), } ) }, @@ -438,7 +468,10 @@ def _run_copy_test( assert result.returncode == 0 - result = subprocess.run(["pdm", "run", "lint:vulture"], cwd=copy_directory) + result = subprocess.run( + ["pdm", "run", "lint:vulture"], + cwd=copy_directory, + ) assert result.returncode == 0 @@ -493,7 +526,7 @@ def test_minimal(license: str, python_version: str) -> None: _run_copy_test( copy_name=f"minimal-{license}-{python_version}", data=_create_data_minimal(license=license, python_version=python_version), - directory_test=_create_directory_test_minimal(license, "not_applicable"), + directory_test=_create_directory_test_minimal(license, "default"), )