Checker of __init__.py files in Python projects
Project description
__init__ file checker
Tool that ensures that __init__.py files are not missing. Various Python tools needs these files, most notably pylint.
Installation
pip install init-file-checker
Installation requires Python 3.8.5 or higher.
Usage
A sample command that checks presence of __init__.py files is:
init-file-checker my_project/
If you want to create missing __init__.py files, use --add-missing command line option:
init-file-checker --add-missing my_project/
The created files will have zero size.
License
MIT
Development setup
-
Make sure you have brew package manager installed.
-
Install pyenv, pyenv-virtualenv and poetry:
brew install pyenv brew install pyenv-virtualenv brew install poetry
-
Add the following lines to
.zshrcor.bash_profileand restart the terminal:# Pyenv settings export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init --path)" eval "$(pyenv virtualenv-init -)"
-
Create Python virtual environment with the correct Python version:
make install-python make create-environment
-
Install all dependencies
make install-dependencies
If you need to delete the Python virtual environment, you can do so with the
command make delete-environment.
Running unit tests and code checks
If you make code change, run unit tests and code checks with the command:
make clean whitespace-format-check isort-check black-check flake8 pydocstyle pylint ruff mypy test coverage
or, equivalently, with the command:
make clean lint test coverage
Each make target runs different checks:
cleandeletes temporary fileswhitespace-format-checkruns whitespace-format checker on all filesisort-checkruns isort checker of imports in*.pyfilesblack-checkruns black code format checker on*.pyfilesflake8runs flake8 code style checker on*.pyfilespydocstyleruns pydocstyle docstring checker on*.pyfilespylintruns pylint code checker on*.pyfilesruffruns ruff code checker on*.pyfilesmypyruns mypy type checker on*.pyfilestestruns unit testscoveragegenerates code coverage reportlintruns all code checks
You can automatically format code with the command:
make isort-format black-format whitespace-format
Modifying dependencies
The list of Python packages that this project depends on is specified in
pyproject.toml and in poetry.lock files. The file pyproject.toml can be
edited by humans. The file poetry.lock is automatically generated by poetry.
Install a development dependency with the command:
poetry add --dev <some_new_python_tool>
Install a new production dependency with the command:
poetry add <some_python_library>
Manual modification of pyproject.toml
Instead of using poetry add command, you can edit pyproject.toml file. Then,
regenerate poetry.lock file with the command:
poetry lock
or the command:
poetry lock --no-update
The latter command does not update already locked packages.
Fixing broken Python environment
If your Python virtual environment becomes broken or polluted with unnecessary packages, delete it, recreate it from scratch and install dependencies a fresh with the following commands:
make delete-environment
make create-environment
make install-dependencies
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file init_file_checker-0.0.2.tar.gz.
File metadata
- Download URL: init_file_checker-0.0.2.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.5.0-14-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d46d472159407aad6d730be35414fb16a6266a00be270ed50a43bccfa6d3419e
|
|
| MD5 |
e2af2d4bdc2f640b8c4901bb57c0d957
|
|
| BLAKE2b-256 |
9333040f9031af19227cef69f61601669772e8accfe51b1a4be0aca30b272c50
|
File details
Details for the file init_file_checker-0.0.2-py3-none-any.whl.
File metadata
- Download URL: init_file_checker-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.5.0-14-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7355ac9968749e65b91b9900e4ed7ed38eda667ad8f8890825eb26cb7966bc84
|
|
| MD5 |
5d6865ec1ba6a2c77b8f0333cafeec8e
|
|
| BLAKE2b-256 |
212145fc0ff1dc641ed26bf0f47bcc7f1a6bc46c8efcc7e71bc13975784b480c
|