A library for safe imports and scoped imports management.
Project description
SafeLib - Import Everything Safe
Safelib is an importer that supports fallback mechanism.
Example Usage
Using Context Manager (sync/async)
import safelib
from safelib import Import
with Import('typing', 'typing_extensions') as importer:
# use traditional import
from safelib import Protocol
# use importer to access the final
final = importer.final
# use get_entity function to import override
override = importer.get_entity('override')
Using Classical Imports
from safelib import _main, typing, _fallback, typing_extensions
from safelib import Protocol
# typing.Protocol or typing_extensions.Protocol
print(Protocol)
Reset State
Import _reset sentinel to reset current state of safelib.
from safelib import _main, httpx
# after get method returned, state will be restored to initial state
from safelib import get, _reset
from safelib import Import
async with Import('typing', 'my_types') as importer:
SafeEntity = importer.SafeEntity
importer.reset_state()
For inquiries, feature request and bug reports, please contact me at contact@tomris.dev
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
safelib-0.2.0.tar.gz
(3.2 kB
view details)
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 safelib-0.2.0.tar.gz.
File metadata
- Download URL: safelib-0.2.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
803af49c2def1117359943861ed64ed759558aea04831da6fa8e9a2e447b8919
|
|
| MD5 |
96e96b737cb44ebb1b01a92c2300e185
|
|
| BLAKE2b-256 |
acfa4d1afa081a316ee294930d7b9c3dbd67b46a640ef3209671426309aa3232
|
File details
Details for the file safelib-0.2.0-py3-none-any.whl.
File metadata
- Download URL: safelib-0.2.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29504c3e46fc9a474f41d6a71985fc943cd843b9f4ed70e1f2fe265e81b5ef63
|
|
| MD5 |
8ac1e8b909f10126db9f47f1ae26f201
|
|
| BLAKE2b-256 |
b62132df42e25dc1100360b72e2aae54b3cfb5dc5ec9e27ceddc850c8f8651ed
|