Skip to content

.initialize_new_project.sh fails on ruff and pytest-check pre-commit checks #542

@hombit

Description

@hombit

Reproducible example

copier copy gh:lincc-frameworks/python-project-template new_project
# Select simple and and answer other questions 
cd new_project
python3 -mvenv ~/.virtualenvs/new_project && source ~/.virtualenvs/new_project/bin/activate
bash .initialize_new_project.sh

Note that two checks failed: ruff and pytest-check

Check template version...................................................Passed
- hook id: check-lincc-frameworks-template-version
- duration: 0.27s
Clear output from Jupyter notebooks......................................Passed
Prevent main branch commits.............................................Skipped
Check for large files....................................................Passed
Validate pyproject.toml..................................................Passed
Validate GitHub Workflows................................................Passed
Lint code using ruff; sort and organize imports..........................Failed
- hook id: ruff
- files were modified by this hook

Found 2 errors (2 fixed, 0 remaining).

Format code using ruff...................................................Passed
Build documentation with Sphinx..........................................Passed
Run unit tests...........................................................Failed
- hook id: pytest-check
- exit code: 1

src/new_project/example_module.py: 2
tests/new_project/test_example_module.py: 2
tests/new_project/test_packaging.py: 1

============================= test session starts ==============================
platform darwin -- Python 3.13.7, pytest-8.4.2, pluggy-1.6.0
rootdir: /private/tmp/new_project
configfile: pyproject.toml
testpaths: tests, src, docs
plugins: anyio-4.11.0, cov-7.0.0
collected 5 items

tests/new_project/test_example_module.py ..                              [ 40%]
tests/new_project/test_packaging.py F                                    [ 60%]
src/new_project/example_module.py ..                                     [100%]

=================================== FAILURES ===================================
_________________________________ test_version _________________________________

    def test_version():
        """Check to see that we can get the package version"""
>       assert new_project.__version__ is not None
               ^^^^^^^^^^^^^^^^^^^^^^^
E       AttributeError: module 'new_project' has no attribute '__version__'. Did you mean: '_version'?

tests/new_project/test_packaging.py:6: AttributeError
================================ tests coverage ================================
_______________ coverage: platform darwin, python 3.13.7-final-0 _______________

Coverage HTML written to dir htmlcov
=========================== short test summary info ============================
FAILED tests/new_project/test_packaging.py::test_version - AttributeError: module 'new_project' has no attribute '__version__'. Did yo...
========================= 1 failed, 4 passed in 0.07s ==========================

.initialize_new_project.sh: Error on line 62: SKIP="no-commit-to-branch" git commit -m "Initial commit"

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions