Skip to main content

Command-line utility, as well as a hook usable by the Python pre-commit framework, 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 (untested) every Python runtime you can think of that implements Python 3 syntax and f-strings.

Quickstart

Without installation (testing out the capabilities):

uvx check-empty -q src/mylib/py.typed docs/.nojekyll static/.gitkeep
# 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 -v

Run the CLI:

check-empty -q src/mylib/py.typed docs/.nojekyll static/.gitkeep

As a pre-commit hook:

# .pre-commit-config.yaml
repos:
- repo: https://github.com/jonathandung/check-empty
  rev: v0.5.0 # repository version
  hooks:
    - id: check-empty # the hook
      args: # example list of arguments
        - --quiet # flag to silence output (equivalent to -q)
        # below: paths to files to clear or keep empty, either relative to the project
        # root or absolute (not shown)
        - src/mylib/py.typed
        - docs/.nojekyll
        - static/.gitkeep

equivalent in prek.toml format:

[[repos]]
repo = "https://github.com/jonathandung/check-empty"
rev = "v0.5.0"
hooks = [{
  id = "check-empty",
  args = [
    "--quiet",
    "src/mylib/py.typed",
    "docs/.nojekyll",
    "static/.gitkeep",
  ]
}]

As a GitHub action step:

steps:
- uses: jonathandung/check-empty@v0.5.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

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

check_empty-0.5.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

check_empty-0.5.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file check_empty-0.5.0.tar.gz.

File metadata

  • Download URL: check_empty-0.5.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","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

Hashes for check_empty-0.5.0.tar.gz
Algorithm Hash digest
SHA256 03eab4353e23023597300ea71ce0e56a2712091bedca385a3d34cd13d722d820
MD5 e8e3524753567aea931c6b4345dcc5a3
BLAKE2b-256 983c1bf8c54d5fd1a0fc9a5fa5b5172c50bd31601945b333dd9e58ed6d24b684

See more details on using hashes here.

File details

Details for the file check_empty-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: check_empty-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","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

Hashes for check_empty-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db543ebc5d6a120227abb2809e024d3f210acc976a46477e0258ba19cace58a0
MD5 4fcb6012f96d53d662de7bab5a2aee45
BLAKE2b-256 df6dc7861c56b959f011a1226f5eccb17ece8d46807cd316b2cee21ba9cfa270

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page