-
-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add compat modules for
tomllib
and importlib.metadata
- Loading branch information
Showing
5 changed files
with
35 additions
and
29 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
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,17 @@ | ||
from __future__ import annotations | ||
|
||
import sys | ||
|
||
if sys.version_info >= (3, 10): | ||
from importlib.metadata import PackageMetadata | ||
else: | ||
from typing import Any, Protocol, TypeVar, overload | ||
|
||
_T = TypeVar("_T") | ||
|
||
class PackageMetadata(Protocol): | ||
@overload | ||
def get_all(self, name: str, failobj: None = None) -> list[Any] | None: ... | ||
|
||
@overload | ||
def get_all(self, name: str, failobj: _T) -> list[Any] | _T: ... |
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,11 @@ | ||
from __future__ import annotations | ||
|
||
import sys | ||
|
||
if sys.version_info >= (3, 11): | ||
from tomllib import TOMLDecodeError, load, loads | ||
else: | ||
from tomli import TOMLDecodeError, load, loads | ||
|
||
|
||
__all__ = ["loads", "load", "TOMLDecodeError"] |
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