Skip to content

get_args_tuple() doesn't take **kwargs into account #83

@JelleZijlstra

Description

@JelleZijlstra

Running this:

import qcore

counter = 0


class X:
    @qcore.caching.cached_per_instance()
    def cached(self, **kwargs):
        global counter
        counter += 1
        return counter


x = X()
print(x.cached(a=1))
print(x.cached(a=2))

Prints 1, 1 (we'd expect 1, 2).

This is because the get_args_tuple() function (https://github.com/quora/qcore/blob/master/qcore/caching.py#L321) ignores **kwargs that are not recognized.

I see a few other problems:

  • *args isn't handled either
  • Python 3.8+ positional-only params are ignored.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions