Skip to content

Commit

Permalink
apply pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed May 31, 2021
1 parent 0fe1ce4 commit 6f0482e
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ assignees: ''
For typos and doc fixes, please go ahead and:

1. Create an issue.
2. Fix the typo.
2. Fix the typo.
3. Submit a PR.

Thanks!
8 changes: 4 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Before submitting

- [ ] Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
- [ ] Did you make sure to update the docs?
- [ ] Did you write any new necessary tests?
- [ ] Did you make sure to update the docs?
- [ ] Did you write any new necessary tests?

## What does this PR do?
Fixes # (issue).

## PR review
Anyone in the community is free to review the PR once the tests have passed.
## PR review
Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

## Did you have fun?
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Build
run: >-
python setup.py sdist bdist_wheel
# We do this, since failures on test.pypi aren't that bad
- name: Publish to Test PyPI
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Another more complex example is using argument mapping is:
import logging
from sklearn.metrics import accuracy_score
from deprecate import deprecated, void

@deprecated(
# use standard sklearn accuracy implementation
target=accuracy_score,
Expand All @@ -122,7 +122,7 @@ Another more complex example is using argument mapping is:
"""My deprecated function which is mapping to sklearn accuracy."""
# to stop complain your IDE about unused argument you can use void/empty function
return void(preds, target, blabla)

# call this function will raise deprecation warning:
# WARNING:root:`depr_accuracy` was deprecated, use `sklearn.metrics.accuracy_score`
print(depr_accuracy([1, 0, 1, 2], [0, 1, 1, 2], 1.23))
Expand Down Expand Up @@ -193,10 +193,10 @@ Eventually you can set multiple deprecation levels via chaining deprecation argu

<details>
<summary>Multiple deprecation levels</summary>

```python
from deprecate import deprecated

@deprecated(
True, "0.3", "0.6", args_mapping=dict(c1='nc1'),
template_mgs="Depr: v%(deprecated_in)s rm v%(remove_in)s for args: %(argument_map)s."
Expand All @@ -207,7 +207,7 @@ Eventually you can set multiple deprecation levels via chaining deprecation argu
)
def any_pow(base, c1: float = 0, nc1: float = 0, nc2: float = 2) -> float:
return base**nc2

# call this function will raise deprecation warning:
# DeprecationWarning('Depr: v0.3 rm v0.6 for args: `c1` -> `nc1`.')
# DeprecationWarning('Depr: v0.4 rm v0.7 for args: `nc1` -> `nc2`.')
Expand Down Expand Up @@ -304,4 +304,4 @@ print(inst.my_d) # returns: "efg"

## Contribution

Have you faced this in past or even now, do you have good ideas for improvement, all is welcome!
Have you faced this in past or even now, do you have good ideas for improvement, all is welcome!
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
show_downloads: true
theme: jekyll-theme-slate
theme: jekyll-theme-slate
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ order_by_type = False
multi_line_output = 3
include_trailing_comma = True


[yapf]
based_on_style = pep8
spaces_before_comment = 2
Expand Down
26 changes: 13 additions & 13 deletions tests/collection_deprecate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@

@deprecated(target=None, deprecated_in="0.2", remove_in="0.3")
def depr_sum_warn_only(a: int, b: int = 5) -> int:
void(a, b)
return void(a, b)


@deprecated(target=base_sum_kwargs, deprecated_in="0.1", remove_in="0.5")
def depr_sum(a: int, b: int = 5) -> int:
void(a, b)
return void(a, b)


@deprecated(target=base_sum_kwargs, deprecated_in="0.1", remove_in="0.6", stream=None)
def depr_sum_no_stream(a: int, b: int = 5) -> int:
void(a, b)
return void(a, b)


@deprecated(target=base_sum_kwargs, deprecated_in="0.1", remove_in="0.7", num_warns=2)
def depr_sum_calls_2(a: int, b: int = 5) -> int:
void(a, b)
return void(a, b)


@deprecated(target=base_sum_kwargs, deprecated_in="0.1", remove_in="0.7", num_warns=-1)
def depr_sum_calls_inf(a: int, b: int = 5) -> int:
void(a, b)
return void(a, b)


@deprecated(
Expand All @@ -43,37 +43,37 @@ def depr_sum_calls_inf(a: int, b: int = 5) -> int:
template_mgs="v%(deprecated_in)s: `%(source_name)s` was deprecated, use `%(target_name)s`"
)
def depr_sum_msg(a: int, b: int = 5) -> int:
void(a, b)
return void(a, b)


@deprecated(target=base_pow_args, deprecated_in="1.0", remove_in="1.3", template_mgs=_SHORT_MSG_FUNC)
def depr_pow_args(a: float, b: float) -> float:
void(a, b)
return void(a, b)


@deprecated(target=base_pow_args, deprecated_in="0.1", remove_in="0.5")
def depr_pow_mix(a: int, b: float = 4) -> float:
void(a, b)
return void(a, b)


@deprecated(target=base_pow_args, deprecated_in="0.1", remove_in="0.5")
def depr_pow_wrong(a: int, c: float = 4) -> float:
void(a, c)
return void(a, c)


@deprecated(target=accuracy_score, args_mapping={'preds': 'y_pred', 'yeah_arg': None})
@deprecated(target=accuracy_score, args_mapping={'preds': 'y_pred', 'yeah_arg': None}) # type: ignore
def depr_accuracy_skip(preds: list, y_true: tuple = (0, 1, 1, 2), yeah_arg: float = 1.23) -> float:
void(preds, y_true, yeah_arg)
return void(preds, y_true, yeah_arg)


@deprecated(target=accuracy_score, args_mapping={'preds': 'y_pred', 'truth': 'y_true'})
def depr_accuracy_map(preds: list, truth: tuple = (0, 1, 1, 2)) -> float:
void(preds, truth)
return void(preds, truth)


@deprecated(target=accuracy_score, args_extra={'y_pred': (0, 1, 1, 1)})
def depr_accuracy_extra(y_pred: list, y_true: tuple = (0, 1, 1, 2)) -> float:
void(y_pred, y_true)
return void(y_pred, y_true)


@deprecated(target=True, deprecated_in="0.1", remove_in="0.5", args_mapping={'coef': 'new_coef'})
Expand Down
2 changes: 1 addition & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ check-manifest
twine>=3.2
isort>=5.0
mypy>=0.790
yapf>=0.29.0
yapf>=0.29.0

0 comments on commit 6f0482e

Please sign in to comment.