Skip to content

Commit

Permalink
[pyright] [core] _utils/backcompat (#11696)
Browse files Browse the repository at this point in the history
### Summary & Motivation

Fix type error and remove `**kwargs` in favor of explicit keyword args
in `canonicalize_backcompat_args`.

### How I Tested These Changes

BK
  • Loading branch information
smackesey committed Jan 15, 2023
1 parent 0da0a90 commit 2b77726
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions python_modules/dagster/dagster/_utils/backcompat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import warnings
from typing import Callable, Optional, TypeVar, cast
from typing import Callable, Optional, TypeVar

import dagster._check as check

Expand All @@ -14,7 +14,15 @@


def canonicalize_backcompat_args(
new_val: T, new_arg: str, old_val: T, old_arg: str, breaking_version: str, **kwargs: object
new_val: T,
new_arg: str,
old_val: T,
old_arg: str,
breaking_version: str,
coerce_old_to_new: Optional[Callable[[T], T]] = None,
additional_warn_txt: Optional[str] = None,
# stacklevel=3 punches up to the caller of canonicalize_backcompat_args
stacklevel: int = 3,
) -> T:
"""
Utility for managing backwards compatibility of two related arguments.
Expand Down Expand Up @@ -49,16 +57,11 @@ def is_new(old_flag=None, new_flag=None):
canonicalize_backcompat_args returns the value as if *only* new_val were specified
"""
coerce_old_to_new = cast(Optional[Callable], kwargs.get("coerce_old_to_new"))
additional_warn_txt = kwargs.get("additional_warn_txt")
# stacklevel=3 punches up to the caller of canonicalize_backcompat_args
stacklevel = kwargs.get("stacklevel", 3)

check.str_param(new_arg, "new_arg")
check.str_param(old_arg, "old_arg")
check.opt_callable_param(coerce_old_to_new, "coerce_old_to_new")
check.opt_str_param(additional_warn_txt, "additional_warn_txt")
check.opt_int_param(stacklevel, "stacklevel")
check.int_param(stacklevel, "stacklevel")
if new_val is not None:
if old_val is not None:
check.failed(
Expand Down

0 comments on commit 2b77726

Please sign in to comment.