Command-line utility, as well as a hook usable by the Python pre-commit framework and a GitHub Action, to ensure that selected files are empty.
Project description
check-empty
A simple, dependency-free and intuitive pre-commit / prek hook, CLI, library and GitHub Action conglomerate that makes sure selected files are empty according to a filesystem stat call and clears them effectively with minimal I/O if required, written in Python. Also available as a tool on uv. Supports CPython 3.6+, PyPy 7.0+, GraalPy 19.0+ and most likely every Python 3.6 runtime you can think of.
Quickstart
Without installation (testing out the capabilities):
uvx check-empty -Q src/mylib/py.typed docs/.nojekyll static/.gitkeep some_directory
# uv
uv tool install check-empty # bare executable on PATH
uv pip install check-empty # if you want the library as well
pip install check-empty # pip
Check the version with:
check-empty --version # or check-empty -v
Run the CLI:
check-empty -Q src/mylib/py.typed docs/.nojekyll static/.gitkeep some_directory
As a pre-commit hook:
# .pre-commit-config.yaml
repos:
- repo: https://github.com/jonathandung/check-empty
rev: v0.6.0 # repository version
hooks:
- id: check-empty # the hook
args: # example list of arguments
- -Q # flag to silence output (shorthand for --quiet)
# below: paths to files/directories to clear or keep empty, relative to project
# root (absolute paths are possible but not recommended)
- src/mylib/py.typed
- docs/.nojekyll
- static/.gitkeep
- some_directory
equivalent in prek.toml format:
[[repos]]
repo = "https://github.com/jonathandung/check-empty"
rev = "v0.6.0"
[[repos.hooks]]
id = "check-empty"
args = [
"-Q",
"src/mylib/py.typed",
"docs/.nojekyll",
"static/.gitkeep",
"some_directory"
]
or a more terse format (TOML 1.1+):
[[repos]]
repo = "https://github.com/jonathandung/check-empty"
rev = "v0.6.0"
hooks = [{
id = "check-empty",
args = [
"-Q", "src/mylib/py.typed", "docs/.nojekyll", "static/.gitkeep", "some_directory"
]
}]
As a GitHub action step:
steps:
- uses: jonathandung/check-empty@v0.6.0 # the latest version on the GitHub Actions
# marketplace; this step will fail and subsequent jobs will not run if any file is
# not empty
with:
python-version: '3.14' # run the script on the latest stable Python version
# Python down to 3.6 is supported but not recommended due to end-of-life
quiet: true
filenames: |
src/mylib/py.typed
docs/.nojekyll
static/.gitkeep
some_directory
Development
If you wish to contribute to this project, you are more than welcome, but please remember to read the contributing guide.
Project details
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 check_empty-0.6.0.tar.gz.
File metadata
- Download URL: check_empty-0.6.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e8daa97681b3c53ea8ef7d1ec53dfcc93d911f772cd41a05c03b61b4efd27d2
|
|
| MD5 |
aa9662c84ea541541297351f3781eb85
|
|
| BLAKE2b-256 |
0a35b1329a3b5a27f8da4deec149f40d6564cde9efa3d2f7499eb584cc81fb30
|
File details
Details for the file check_empty-0.6.0-py3-none-any.whl.
File metadata
- Download URL: check_empty-0.6.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
211ec57421404a04825176014f993521774ddb75abdc9daec20b8af346e58014
|
|
| MD5 |
628e6c92fae7218a8442917918d73f6a
|
|
| BLAKE2b-256 |
de1bf66b90b7f36e52e463a1fe4b62d3f44b8e54e2e5aa476347bc75f0b5a33d
|