Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate_kwarg_name is not type aware #1308

Closed
thelittlebug opened this issue Apr 9, 2023 · 3 comments · Fixed by #1348
Closed

deprecate_kwarg_name is not type aware #1308

thelittlebug opened this issue Apr 9, 2023 · 3 comments · Fixed by #1348
Labels
bug Something isn't working

Comments

@thelittlebug
Copy link
Contributor

thats the reason why you get no autocompletion for simple things like the following

Workplane().text("You rock", 12, 5,). #at this point the editor does not know how to autocomplete

but there is a simple solution to this issue:

TCallable = TypeVar("TCallable", bound=Callable)

class deprecate_kwarg_name:
    def __init__(self, name, new_name):
        self.name = name
        self.new_name = new_name

    def __call__(self, f: TCallable) -> TCallable:
        @wraps(f)
        def wrapped(*args, **kwargs):

            if self.name in kwargs:
                warn(
                    f"Kwarg <{self.name}> will be removed. Please use <{self.new_name}>",
                    FutureWarning,
                )

            return f(*args, **kwargs)

        return cast(TCallable, wrapped)
@adam-urbanczyk
Copy link
Member

Could you open a PR?

@thelittlebug
Copy link
Contributor Author

yes, i will definitely do this. sry, i hadn't the possibilities for that while i was posting this. 1-2 days and i'm in my used to work area ;)

@voneiden
Copy link
Contributor

@thelittlebug I've opened PR #1348 on your behalf, you OK with that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants