Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bugfix: Uniswap constructor and "check_approval" decorator throwing whenever passing kwargs. Issue #218#361

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

RoscoeTheDog
Copy link

Asked the chatbot to come up with a solution. Seems to work fine. I'm not too familiar with all the internal relationships, so someone should review before merging. 👍

When creating a wrapper class for this API, I encountered issues passing down a flattened dict of kwargs to the constructor of Uniswap() class due to it not having *args, **kwargs in it's constructors signature. Any extra arguments that were not explicitily in the constructors signature would throw an error, which makes it less friendly for other software systems to wrap it's code with.Simply adding *args and **kwargs to the constructor fixes this issue and doesn't intrtoduce any negative effects.
@RoscoeTheDog
Copy link
Author

Also added *args, **kwargs to Uniswap constructor

When creating a wrapper class for this API, I encountered issues passing down a flattened dict of kwargs to the constructor of Uniswap() class due to it not having *args, **kwargs in it's constructors signature. Any extra arguments that were not explicitily in the constructors signature would throw an error, which makes it less friendly for other software systems to wrap it's code with.

Simply adding *args and **kwargs to the constructor fixes this issue and doesn't intrtoduce any negative effects.

@RoscoeTheDogRoscoeTheDog changed the titlebugfix: "check_approval" decorator throwing when using kwargs. Issue #218bugfix: Uniswap constructor and "check_approval" decorator throwing whenever passing kwargs. Issue #218Dec 24, 2023
Simulate can now be specified to return an estimate of the gas fees as well as some other useful metadata for the transaction. Does NOT take into account slippage or price impact for a transaction!!This was mostly needed so I could find the gas fees ahead of time before pushing an order on-chain and allows me to adjust the amount of network fee token buyback prior to it.
bug fixes when building and pushing transactions
Copy link
Member

@ErikBjareErikBjare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Any extra arguments that were not explicitily in the constructors signature would throw an error

That is intended. Don't pass things that aren't going to be used.

which makes it less friendly for other software systems to wrap it's code with.

No, it just makes you have to clean up your args (as you should anyway).

Simply adding *args and **kwargs to the constructor fixes this issue and doesn't intrtoduce any negative effects.

It's not a bug, it's a feature. Adding unused args and kwargsdoes introduce negative effects. It ruins typecheckers ability to spot misspelled keyword arguments and otherwise unused args, among other things.

As explained above, this PR breaks typing in several places (see CI), so it will not get merged.

Comment on lines +95 to +96
*args,
**kwargs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Unused. Don't do this, clean up your args instead.

Comment on lines -23 to +29
def check_approval(
method: Callable[Concatenate["Uniswap", P], T]
) -> Callable[Concatenate["Uniswap", P], T]:
"""Decorator to check if user is approved for a token. It approves them if they
def check_approval(method: Callable[..., T]) -> Callable[..., T]:
"""Decorator to check if the user is approved for a token. It approves them if they
need to be approved."""

@functools.wraps(method)
def approved(self: "Uniswap", *args:P.args,**kwargs:P.kwargs) -> T:
def approved(self: "Uniswap", *args:Union[AddressLike, int],**kwargs:AddressLike) -> T:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This ruins typing (and is not even valid,*args has to be an iterable and**kwargs a mapping) for any function annotated withcheck_approval. TheParamSpec is used for a reason.

@ErikBjare
Copy link
Member

ErikBjare commentedJul 4, 2024
edited
Loading

If you want a fix for#218, feel free to submit a PR that checks thekwargs for the token in addition to theargs (or just skip the kwargs) as I explained in#218 (comment).

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ErikBjareErikBjareErikBjare left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@RoscoeTheDog@ErikBjare

[8]ページ先頭

©2009-2025 Movatter.jp