Skip to content

Commit

Permalink
switch from isort to ruff/I
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed Oct 1, 2023
1 parent cc58214 commit 89d593b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 30 deletions.
6 changes: 0 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ repos:
# - id: docformatter
# args: [--in-place]

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
name: imports

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ line-length = 120
select = [
"E", "W", # see: https://pypi.org/project/pycodestyle
"F", # see: https://pypi.org/project/pyflakes
"I", # isort
"D", # see: https://pypi.org/project/pydocstyle
"N", # see: https://pypi.org/project/pep8-naming
"S", # see: https://pypi.org/project/flake8-bandit
Expand Down
26 changes: 3 additions & 23 deletions src/deprecate/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
"""
import inspect
from functools import partial, wraps
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
from typing import Any, Callable, Dict, Optional, Union
from warnings import warn

from deprecate.deprecation import get_func_arguments_types_defaults

Check notice

Code scanning / CodeQL

Module imports itself Note

The module 'deprecate.deprecation' imports itself.

#: Default template warning message fot redirecting callable
TEMPLATE_WARNING_CALLABLE = (
"The `%(source_name)s` was deprecated since v%(deprecated_in)s in favor of `%(target_path)s`."
Expand All @@ -27,28 +29,6 @@
deprecation_warning = partial(warn, category=FutureWarning)


def get_func_arguments_types_defaults(func: Callable) -> List[Tuple[str, Tuple, Any]]:
"""Parse function arguments, types and default values.
Args:
func: a function to be xeamined
Returns:
sequence of details for each position/keyward argument
Example:
>>> get_func_arguments_types_defaults(get_func_arguments_types_defaults)
[('func', typing.Callable, <class 'inspect._empty'>)]
"""
func_default_params = inspect.signature(func).parameters
func_arg_type_val = []
for arg in func_default_params:
arg_type = func_default_params[arg].annotation
arg_default = func_default_params[arg].default
func_arg_type_val.append((arg, arg_type, arg_default))
return func_arg_type_val


def _update_kwargs_with_args(func: Callable, fn_args: tuple, fn_kwargs: dict) -> dict:
"""Update in case any args passed move them to kwargs and add defaults.
Expand Down
25 changes: 24 additions & 1 deletion src/deprecate/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,32 @@
Copyright (C) 2020-2023 Jiri Borovec <...>
"""
import inspect
import warnings
from contextlib import contextmanager
from typing import Any, Generator, List, Optional, Type, Union
from typing import Any, Generator, List, Optional, Type, Union, Callable, Tuple


def get_func_arguments_types_defaults(func: Callable) -> List[Tuple[str, Tuple, Any]]:
"""Parse function arguments, types and default values.
Args:
func: a function to be xeamined
Returns:
sequence of details for each position/keyward argument
Example:
>>> get_func_arguments_types_defaults(get_func_arguments_types_defaults)
[('func', typing.Callable, <class 'inspect._empty'>)]
"""
func_default_params = inspect.signature(func).parameters
func_arg_type_val = []
for arg in func_default_params:
arg_type = func_default_params[arg].annotation
arg_default = func_default_params[arg].default
func_arg_type_val.append((arg, arg_type, arg_default))
return func_arg_type_val


def _warns_repr(warns: List[warnings.WarningMessage]) -> List[Union[Warning, str]]:
Expand Down

0 comments on commit 89d593b

Please sign in to comment.