requirements_dev.txt
contains packages for running tests.
Use tree
with flag -a
to print all files, -I
to exclude some files, and
pipe the output to clip.exe
to copy to clipboard.
Command to generate tree structure:
tree -a -I '<files_to_be_excluded>|.git|.venv|<more_files_or_folders>' | clip.exe
.
├── .github
│ └── workflows
│ └── tests.yml
├── .gitignore
├── README.md
├── pyproject.toml
├── requirements.txt
├── requirements_dev.txt
├── setup.cfg
├── setup.py
├── src
│ └── data_structures
│ ├── __init__.py
│ └── linked_list.py
├── tests
│ ├── __init__.py
│ ├── conftest.py
│ ├── test_linked_list.py
│ └── test_linked_list_node.py
└── tox.ini
For mypy
, testing only the src
directory:
mypy src
For flake8
, to test both the src
and tests
directory:
flake8 src tests
For pytest
:
pytest
Generate pytest
coverage report with:
pytest --cov-report='html'
MyPy is a static type checker, to check if variable types are what you expect them to be.
MyPy's is None
type guard, to check if something is None
or not:
def func(val: Optional[str]):
"""Example for `is None` type guard."""
if val is not None:
# explicitly use `val is not None`, not just `val`
# Here, type of val is narrowed to str
print(val)
else:
# can optionally skip else
# Type of val is now narrowed to None
pass