force-relative-import
This is a library that forcibly enables Python relative import, allowing you to ignore Python's relative import restrictions.
这是一个强制启用python相对导入的库,允许你忽略python的相对导入限制。
Install / 安装
pip install -U force-relative-import
Usage Method / 使用方法
Method 1 (Recommend) / 方法1 (推荐)
Use scopes to avoid unexpected situations.
使用作用域,以避免意外情况。
from force_relative_import import enable_force_relative_import
with enable_force_relative_import():
from .moduleA import return_good
print(return_good())
from force_relative_import import enable_force_relative_import
with enable_force_relative_import():
from ..moduleA import return_good
print(return_good())
from force_relative_import import enable_force_relative_import
with enable_force_relative_import():
from ...moduleA import return_good
print(return_good())
Method 2 / 方法2
Using functions.
使用函数。
from force_relative_import import enable_force_relative_import, global_enable_force_relative_import, global_disable_force_relative_import
global_enable_force_relative_import()
from .moduleA import return_good
global_disable_force_relative_import()
print(return_good())
Method 3 / 方法3
Recommended only for main programs, not for modules or packages.
仅建议用于主程序,不要用于模块或包。
from force_relative_import import enable_now
from .moduleA import return_good
print(return_good())
Metadata
Release files for force-relative-import 0.0.3.post1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| force_relative_import-0.0.3.post1.tar.gz | 3.7 kB | Without provenance | Details for force_relative_import-0.0.3.post1.tar.gz |
Release files / force_relative_import-0.0.3.post1.tar.gz
| Download URL | force_relative_import-0.0.3.post1.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e5fb2f9ff8d3fb0553c80ec8deb04f12d151a9c548db160af95feb42d01e0ca
|
|
BLAKE2b-256 checksum How to use checksums |
56920c3e94a167582cb4cf0bdb886d487dfd2048893b3ce8fa5b89c4100d1ded
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|
Security for force-relative-import 0.0.3.post1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.