-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #287 from neutrinoceros/perf/minimize_importtime
PERF: delay most costly import statements until they are needed
- Loading branch information
Showing
3 changed files
with
36 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,24 @@ | ||
from __future__ import annotations | ||
|
||
from .io import dump | ||
from .io import dumps | ||
from .io import load | ||
from .io import loads | ||
from .validation import validate_inifile_schema | ||
from .format import format_string | ||
|
||
from importlib.metadata import version | ||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: # pragma: no cover | ||
from typing import Any | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
if name == "__version__": | ||
from importlib.metadata import version | ||
|
||
return version("inifix") | ||
raise AttributeError(f"module {__name__!r} has no attribute {name!r}") | ||
|
||
|
||
__version__ = version("inifix") | ||
del version | ||
del TYPE_CHECKING |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from importlib.metadata import version | ||
|
||
import pytest | ||
|
||
import inifix | ||
|
||
|
||
def test_dunder_version(): | ||
assert inifix.__version__ == version("inifix") | ||
|
||
|
||
def test_unknown_member(): | ||
with pytest.raises(AttributeError): | ||
inifix.unknown_member # noqa: B018 |