ib-api-reloaded / ib_async

Python sync/async framework for Interactive Brokers API (replaces ib_insync)
BSD 2-Clause "Simplified" License
463 stars 73 forks source link

Remove mutable default arguments #81

Open npbaskerville opened 1 month ago

npbaskerville commented 1 month ago

For example reqHistoricalData has a mutable default argument. I won't list them all here, but a simple PR is required to replace any such cases with immutable default args. Since the code is typed, it will be easy to search for e.g. : List[ and find some of them.

I'm happy to contribute the PR

mattsta commented 1 month ago

Good catch.

It looks like most of cases are only parameters for sending data, so technically it's "safe" because the methods never modify the parameters, but still good to be more correct overall.

Feel free to update and add a PR. Just use the next branch for updates.

The data sending API treats empty lists and None as the same value (both just send ""), so modification should be as simple as updating defaults to list[thing] | None = None almost everywhere.