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.5.0.tar.gz
(3.7 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.5.0.tar.gz.
File metadata
- Download URL: safelib-0.5.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70e9bcd33370ce415b3370d444acee7d53fee9dfd6c7d59f9db615d331732472
|
|
| MD5 |
f3d801d6ddcd2c49e4e26f098ece4c3a
|
|
| BLAKE2b-256 |
90d947035e5fe93a2d441308f0bdb67d4a3eee68163a6b113b7cb92ee31dc77f
|
File details
Details for the file safelib-0.5.0-py3-none-any.whl.
File metadata
- Download URL: safelib-0.5.0-py3-none-any.whl
- Upload date:
- Size: 3.9 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 |
07574ce067979b07f37d3fb15ca57a9f8b36668bb3f27eda8e68671535925370
|
|
| MD5 |
00ad5c77a9a5e6cd8833489fa8394ca3
|
|
| BLAKE2b-256 |
5b44a243086bc7a951cb014383b721fa27f650828e95b6959fa9d45eff1460c1
|