-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding py.typed for mypy support (thanks to Dominic) * Adding testing for Python 3.10-dev * Fixing #189 by adding mappings for mypy * Fixing setdefault behavior with box_dots (thanks to ipcoder) * Changing #193 how magic methods are handled with default_box (thanks to Rexbard) Co-authored-by: Dominic <[email protected]>
- Loading branch information
1 parent
9170539
commit 51042b8
Showing
24 changed files
with
394 additions
and
43 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,3 +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: ... |
Oops, something went wrong.