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

FuzzyAttribute actually should be named as FuzzyFunction #961

Open
PerchunPak opened this issue Jul 10, 2022 · 5 comments
Open

FuzzyAttribute actually should be named as FuzzyFunction #961

PerchunPak opened this issue Jul 10, 2022 · 5 comments
Labels

Comments

@PerchunPak
Copy link

The problem

There is LazyFunction (takes callable, without args) and LazzyAttribute (takes callable with one argument - self). But only one fuzzy class - FuzzyAttribute, which actually takes the same as LazyFunction.

Proposed solution

I would like to see FuzzyAttribute that takes callable and argument self in it, and fix this fuzzy naming in fuzzy functions.

@francoisfreitag
Copy link
Member

Agreed on principle. There needs to be a deprecation period for this transition, as many codebases rely on FuzzyAttribute signature. The outline should be:

  1. Create a FuzzyFunction and deprecate FuzzyAttribute (raise a deprecation warning when it’s used, suggesting to rename FuzzyAttribute to FuzzyFunction)
  2. On the next major version, remove FuzzyAttribute
  3. On the next version, introduce back FuzzyAttribute, and pass its fuzzer the instance being built (argument self)

@PerchunPak
Copy link
Author

Or just check if the given callable takes no arguments, if true - raise a warning.

This is how it can be done.

@rbarrois
Copy link
Member

That's a good suggestion indeed, although the existing fuzzy module only provides declaration that are totally isolated from the existing factory.

The implementation I envision is:

  • Add a new factory.fuzzy.FuzzyFunction, which mirrors the current factory.fuzzy.FuzzyAttribute;
  • Add some logic in factory.fuzzy.FuzzyAttribute to provide a DeprecationWarning` if the provided callable takes no parameter;
  • Update the documentation.

@PerchunPak
Copy link
Author

It could be more detailed:

  1. Rename FuzzyAttribute to FuzzyFunction.
  2. Add new implementation of FuzzyFunction, which accepts only a callable with one argument.
  3. Proxy all logic from FuzzyFunction to FuzzyAttribute (and raise warning) if the given callable is without arguments (check this with inspect.signature).
  4. Update the documentation.

These all (of course) in one PR, or even one commit.


I will do this, when I will have some free time. It's very doubtful, that it will be soon, so if someone wants to implement it right now - you're free to do this.

@PerchunPak
Copy link
Author

I will do this, when I will have some free time. It's very doubtful, that it will be soon, so if someone wants to implement it right now - you're free to do this.

Not in this year 100%, maybe next too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants