Add import responsible for postponed evaluation of annotations to python files
Project description
import-future-annotations
Tool that checks presence of import from __future__ import annotations
in python files and adds it if it's missing.
Installation
pip install import-future-annotations
Usage
import-future-annotations
takes filenames as positional arguments.
Additional options:
--check-only
: Don't modify files, only check. If script is applicable to any given file, the exit status code will be 1.--allow-empty
: Add import to empty python files aswell.
As a pre-commit hook
See pre-commit for instructions
Sample .pre-commit-config.yaml
:
- repo: https://github.com/mbroton/import-future-annotations
rev: v0.1.0
hooks:
- id: import-future-annotations
How does it work?
file.py
before:
import os
import sys
...
Run pre-commit hook or execute command:
> import-future-annotations file.py
Adding annotations import to file.py
file.py
after:
+ from __future__ import annotations
import os
import sys
It will be added always on top of the file.
It won't add any blank lines, so I suggest to use/place it before reorder_python_imports
hook.
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
Close
Hashes for import_future_annotations-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7ff680e473a9c7c389d923e7a2596cb2e29ffd4e9dfe073f8a2b7878d911e0f |
|
MD5 | fb359cc73b4938d843082bf963d025ae |
|
BLAKE2b-256 | 43767577f66df3f9f48076d4d5606103872abbab87f8d0a89374c7a407e4afb2 |
Close
Hashes for import_future_annotations-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71db743fffad9ff6466ceb4356b3e371586d78b58e0b5621f8436bb480970135 |
|
MD5 | 269334921b6052e528cc9d0e412ec81b |
|
BLAKE2b-256 | 9e3658431feeeafe1076ef2028f23a61182a3240d910cdf3c7f67dfcfb14d4a0 |