scverse / scanpy

Single-cell analysis in Python. Scales to >1M cells.
https://scanpy.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.93k stars 603 forks source link

Use deprecation decorator #3380

Closed flying-sheep closed 12 hours ago

flying-sheep commented 1 day ago

Alternative: make the decorator insert the change to docs too, but that’s more involved, as one would have to parse the docstring and figure out where and at what indentation level to insert the deprecation warning directive:

def deprecated(
    msg: LiteralString, /, version: LiteralString, notice: LiteralString *, stacklevel: int = 2
) -> Callable[[Callable[P, R]], Callable[P, R]]:
    def decorator(f_or_c: Callable[P, R], /) -> Callable[P, R]:
        f_or_c.__doc__ = ...  # TODO: insert .. deprecated:: {version}\n{indent(notice, " "*3)}
        return _deprecated(f"(since {version}:) {msg}", category=FutureWarning, stacklevel=stacklevel)(f_or_c)

    return decorator
codecov[bot] commented 1 day ago

Codecov Report

Attention: Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 76.50%. Comparing base (751eafa) to head (735f00a). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/scanpy/_compat.py 75.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #3380 +/- ## ======================================= Coverage 76.49% 76.50% ======================================= Files 111 111 Lines 12867 12874 +7 ======================================= + Hits 9843 9849 +6 - Misses 3024 3025 +1 ``` | [Files with missing lines](https://app.codecov.io/gh/scverse/scanpy/pull/3380?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scverse) | Coverage Δ | | |---|---|---| | [src/scanpy/plotting/\_preprocessing.py](https://app.codecov.io/gh/scverse/scanpy/pull/3380?src=pr&el=tree&filepath=src%2Fscanpy%2Fplotting%2F_preprocessing.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scverse#diff-c3JjL3NjYW5weS9wbG90dGluZy9fcHJlcHJvY2Vzc2luZy5weQ==) | `87.71% <100.00%> (+0.21%)` | :arrow_up: | | [...preprocessing/\_deprecated/highly\_variable\_genes.py](https://app.codecov.io/gh/scverse/scanpy/pull/3380?src=pr&el=tree&filepath=src%2Fscanpy%2Fpreprocessing%2F_deprecated%2Fhighly_variable_genes.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scverse#diff-c3JjL3NjYW5weS9wcmVwcm9jZXNzaW5nL19kZXByZWNhdGVkL2hpZ2hseV92YXJpYWJsZV9nZW5lcy5weQ==) | `95.55% <100.00%> (+0.04%)` | :arrow_up: | | [src/scanpy/preprocessing/\_simple.py](https://app.codecov.io/gh/scverse/scanpy/pull/3380?src=pr&el=tree&filepath=src%2Fscanpy%2Fpreprocessing%2F_simple.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scverse#diff-c3JjL3NjYW5weS9wcmVwcm9jZXNzaW5nL19zaW1wbGUucHk=) | `89.94% <100.00%> (+0.02%)` | :arrow_up: | | [src/scanpy/\_compat.py](https://app.codecov.io/gh/scverse/scanpy/pull/3380?src=pr&el=tree&filepath=src%2Fscanpy%2F_compat.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scverse#diff-c3JjL3NjYW5weS9fY29tcGF0LnB5) | `81.81% <75.00%> (-0.29%)` | :arrow_down: |

🚨 Try these New Features: