-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mypy stubs and general maintenance (#202)
* Adding testing for Python 3.10-dev * Changing to use tomli instead of toml by default as it is faster and toml 1.0.0 compatible * Fixing #189 by adding mappings for mypy
- Loading branch information
1 parent
b61d165
commit 2183dbc
Showing
23 changed files
with
365 additions
and
34 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 |
---|---|---|
@@ -1,21 +1,39 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.5.0 | ||
rev: v4.0.1 | ||
hooks: | ||
- id: mixed-line-ending | ||
- id: trailing-whitespace | ||
# Identify invalid files | ||
- id: check-ast | ||
- id: check-yaml | ||
- id: check-json | ||
- id: check-toml | ||
# git checks | ||
- id: check-merge-conflict | ||
- id: check-added-large-files | ||
exclude: ^test/data/.+ | ||
- id: detect-private-key | ||
- id: check-case-conflict | ||
# Python checks | ||
- id: check-docstring-first | ||
- id: debug-statements | ||
- id: requirements-txt-fixer | ||
- id: fix-encoding-pragma | ||
- id: check-byte-order-marker | ||
- id: debug-statements | ||
- id: check-yaml | ||
- id: fix-byte-order-marker | ||
# General quality checks | ||
- id: mixed-line-ending | ||
args: [--fix=lf] | ||
- id: trailing-whitespace | ||
args: [--markdown-linebreak-ext=md] | ||
- id: check-executables-have-shebangs | ||
- id: end-of-file-fixer | ||
exclude: ^test/data/.+ | ||
- repo: https://github.com/ambv/black | ||
rev: stable | ||
rev: 21.7b0 | ||
hooks: | ||
- id: black | ||
args: [--config=.black.toml] | ||
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: 'v0.770' | ||
rev: 'v0.910' | ||
hooks: | ||
- id: mypy | ||
additional_dependencies: [ruamel.yaml,toml,msgpack] |
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
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,5 +1,4 @@ | ||
include LICENSE | ||
include AUTHORS.rst | ||
include CHANGES.rst | ||
|
||
include box/py.typed |
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
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,115 @@ | ||
from collections.abc import Mapping | ||
from os import PathLike | ||
from typing import Any, Dict, Generator, List, Optional, Tuple, Union | ||
|
||
class Box(dict): | ||
def __new__( | ||
cls: Any, | ||
*args: Any, | ||
default_box: bool = ..., | ||
default_box_attr: Any = ..., | ||
default_box_none_transform: bool = ..., | ||
frozen_box: bool = ..., | ||
camel_killer_box: bool = ..., | ||
conversion_box: bool = ..., | ||
modify_tuples_box: bool = ..., | ||
box_safe_prefix: str = ..., | ||
box_duplicates: str = ..., | ||
box_intact_types: Union[Tuple, List] = ..., | ||
box_recast: Dict = ..., | ||
box_dots: bool = ..., | ||
box_class: Union[Dict, Box] = ..., | ||
**kwargs: Any, | ||
) -> Any: ... | ||
def __init__( | ||
self, | ||
*args: Any, | ||
default_box: bool = ..., | ||
default_box_attr: Any = ..., | ||
default_box_none_transform: bool = ..., | ||
frozen_box: bool = ..., | ||
camel_killer_box: bool = ..., | ||
conversion_box: bool = ..., | ||
modify_tuples_box: bool = ..., | ||
box_safe_prefix: str = ..., | ||
box_duplicates: str = ..., | ||
box_intact_types: Union[Tuple, List] = ..., | ||
box_recast: Dict = ..., | ||
box_dots: bool = ..., | ||
box_class: Union[Dict, Box] = ..., | ||
**kwargs: Any, | ||
) -> None: ... | ||
def __add__(self, other: Mapping[Any, Any]) -> Any: ... | ||
def __radd__(self, other: Mapping[Any, Any]) -> Any: ... | ||
def __iadd__(self, other: Mapping[Any, Any]) -> Any: ... | ||
def __or__(self, other: Mapping[Any, Any]) -> Any: ... | ||
def __ror__(self, other: Mapping[Any, Any]) -> Any: ... | ||
def __ior__(self, other: Mapping[Any, Any]) -> Any: ... | ||
def __sub__(self, other: Mapping[Any, Any]) -> Any: ... | ||
def __hash__(self) -> Any: ... # type: ignore[override] | ||
def __dir__(self): ... | ||
def keys(self, dotted: Union[bool] = ...) -> Any: ... | ||
def items(self, dotted: Union[bool] = ...) -> Any: ... | ||
def get(self, key: Any, default: Any = ...): ... | ||
def copy(self) -> Box: ... | ||
def __copy__(self) -> Box: ... | ||
def __deepcopy__(self, memodict: Any = ...) -> Box: ... | ||
def __getitem__(self, item: Any, _ignore_default: bool = ...): ... | ||
def __getattr__(self, item: Any): ... | ||
def __setitem__(self, key: Any, value: Any): ... | ||
def __setattr__(self, key: Any, value: Any): ... | ||
def __delitem__(self, key: Any): ... | ||
def __delattr__(self, item: Any) -> None: ... | ||
def pop(self, key: Any, *args: Any): ... | ||
def clear(self) -> None: ... | ||
def popitem(self): ... | ||
def __iter__(self) -> Generator: ... | ||
def __reversed__(self) -> Generator: ... | ||
def to_dict(self) -> Dict: ... | ||
def update(self, __m: Optional[Any] = ..., **kwargs: Any) -> None: ... | ||
def merge_update(self, __m: Optional[Any] = ..., **kwargs: Any) -> None: ... | ||
def setdefault(self, item: Any, default: Optional[Any] = ...): ... | ||
def to_json( | ||
self, filename: Union[str, PathLike] = ..., encoding: str = ..., errors: str = ..., **json_kwargs: Any | ||
) -> Any: ... | ||
@classmethod | ||
def from_json( | ||
cls: Any, | ||
json_string: str = ..., | ||
filename: Union[str, PathLike] = ..., | ||
encoding: str = ..., | ||
errors: str = ..., | ||
**kwargs: Any, | ||
) -> Box: ... | ||
def to_yaml( | ||
self, | ||
filename: Union[str, PathLike] = ..., | ||
default_flow_style: bool = ..., | ||
encoding: str = ..., | ||
errors: str = ..., | ||
**yaml_kwargs: Any, | ||
) -> Any: ... | ||
@classmethod | ||
def from_yaml( | ||
cls: Any, | ||
yaml_string: str = ..., | ||
filename: Union[str, PathLike] = ..., | ||
encoding: str = ..., | ||
errors: str = ..., | ||
**kwargs: Any, | ||
) -> Box: ... | ||
def to_toml(self, filename: Union[str, PathLike] = ..., encoding: str = ..., errors: str = ...) -> Any: ... | ||
@classmethod | ||
def from_toml( | ||
cls: Any, | ||
toml_string: str = ..., | ||
filename: Union[str, PathLike] = ..., | ||
encoding: str = ..., | ||
errors: str = ..., | ||
**kwargs: Any, | ||
) -> Box: ... | ||
def to_msgpack(self, filename: Union[str, PathLike] = ..., **kwargs: Any) -> Any: ... | ||
@classmethod | ||
def from_msgpack( | ||
cls: Any, msgpack_bytes: bytes = ..., filename: Union[str, PathLike] = ..., **kwargs: Any | ||
) -> Box: ... |
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,85 @@ | ||
import box | ||
from box.converters import ( | ||
BOX_PARAMETERS as BOX_PARAMETERS, | ||
msgpack_available as msgpack_available, | ||
toml_available as toml_available, | ||
yaml_available as yaml_available, | ||
) | ||
from box.exceptions import BoxError as BoxError, BoxTypeError as BoxTypeError | ||
from os import PathLike as PathLike | ||
from typing import Any, Iterable, Optional, Type, Union | ||
|
||
class BoxList(list): | ||
def __new__(cls, *args: Any, **kwargs: Any): ... | ||
box_options: Any = ... | ||
box_org_ref: Any = ... | ||
def __init__(self, iterable: Iterable = ..., box_class: Type[box.Box] = ..., **box_options: Any) -> None: ... | ||
def __getitem__(self, item: Any): ... | ||
def __delitem__(self, key: Any): ... | ||
def __setitem__(self, key: Any, value: Any): ... | ||
def append(self, p_object: Any) -> None: ... | ||
def extend(self, iterable: Any) -> None: ... | ||
def insert(self, index: Any, p_object: Any) -> None: ... | ||
def __copy__(self): ... | ||
def __deepcopy__(self, memo: Optional[Any] = ...): ... | ||
def __hash__(self) -> Any: ... # type: ignore[override] | ||
def to_list(self): ... | ||
def to_json( | ||
self, | ||
filename: Union[str, PathLike] = ..., | ||
encoding: str = ..., | ||
errors: str = ..., | ||
multiline: bool = ..., | ||
**json_kwargs: Any, | ||
) -> Any: ... | ||
@classmethod | ||
def from_json( | ||
cls: Any, | ||
json_string: str = ..., | ||
filename: Union[str, PathLike] = ..., | ||
encoding: str = ..., | ||
errors: str = ..., | ||
multiline: bool = ..., | ||
**kwargs: Any, | ||
) -> Any: ... | ||
def to_yaml( | ||
self, | ||
filename: Union[str, PathLike] = ..., | ||
default_flow_style: bool = ..., | ||
encoding: str = ..., | ||
errors: str = ..., | ||
**yaml_kwargs: Any, | ||
) -> Any: ... | ||
@classmethod | ||
def from_yaml( | ||
cls: Any, | ||
yaml_string: str = ..., | ||
filename: Union[str, PathLike] = ..., | ||
encoding: str = ..., | ||
errors: str = ..., | ||
**kwargs: Any, | ||
) -> Any: ... | ||
def to_toml( | ||
self, filename: Union[str, PathLike] = ..., key_name: str = ..., encoding: str = ..., errors: str = ... | ||
) -> Any: ... | ||
@classmethod | ||
def from_toml( | ||
cls: Any, | ||
toml_string: str = ..., | ||
filename: Union[str, PathLike] = ..., | ||
key_name: str = ..., | ||
encoding: str = ..., | ||
errors: str = ..., | ||
**kwargs: Any, | ||
) -> Any: ... | ||
def to_msgpack(self, filename: Union[str, PathLike] = ..., **kwargs: Any) -> Any: ... | ||
@classmethod | ||
def from_msgpack( | ||
cls: Any, msgpack_bytes: bytes = ..., filename: Union[str, PathLike] = ..., **kwargs: Any | ||
) -> Any: ... | ||
def to_csv(self, filename: Union[str, PathLike] = ..., encoding: str = ..., errors: str = ...) -> Any: ... | ||
@classmethod | ||
def from_csv( | ||
cls: Any, csv_string: str = ..., filename: Union[str, PathLike] = ..., encoding: str = ..., errors: str = ... | ||
) -> Any: ... | ||
def _dotted_helper(self) -> Any: ... |
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,15 @@ | ||
from box.box import Box as Box | ||
from typing import Any, Optional | ||
|
||
class ConfigBox(Box): | ||
def __getattr__(self, item: Any): ... | ||
def __dir__(self): ... | ||
def bool(self, item: Any, default: Optional[Any] = ...): ... | ||
def int(self, item: Any, default: Optional[Any] = ...): ... | ||
def float(self, item: Any, default: Optional[Any] = ...): ... | ||
def list(self, item: Any, default: Optional[Any] = ..., spliter: str = ..., strip: bool = ..., mod: Optional[Any] = ...): ... # type: ignore | ||
def getboolean(self, item: Any, default: Optional[Any] = ...): ... | ||
def getint(self, item: Any, default: Optional[Any] = ...): ... | ||
def getfloat(self, item: Any, default: Optional[Any] = ...): ... | ||
def copy(self): ... | ||
def __copy__(self): ... |
Oops, something went wrong.