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

Supply chain risk reduction: remove dependency on library named deprecated #2386

Merged
merged 1 commit into from
Oct 30, 2022

Conversation

akx
Copy link
Contributor

@akx akx commented Sep 19, 2022

No need for an external library just for 5 annotations.

Pull Request check-list

Please make sure to review and check all of these items:

  • Does $ tox pass with this change (including linting)?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?
  • Was the change added to CHANGES file?

Description of change

This PR removes the dependency on the @deprecated library in favor of a simple 8-line function.

@akx akx marked this pull request as ready for review September 19, 2022 11:16
@akx akx force-pushed the remove-deprecated-dependency branch from 2901de6 to 3592e04 Compare September 21, 2022 10:45
@chayim
Copy link
Contributor

chayim commented Sep 28, 2022

While this removes the dependency, I don't really see this as necessary. It's less expressive than a decorator - and I'd like to keep that interface. If you'd like to introduce a decorator that provides the same namespace, that's a separate conversation.

As a project, it would appear that deprecated has stalled. But, the need to decorate functions, potentially classes, and definitely arguments exists.

@akx
Copy link
Contributor Author

akx commented Sep 28, 2022

@chayim Thanks for the comments.

My reasoning is that pulling in two dependencies (deprecated and its dependency wrapt) just to basically format a string and call warnings.warn() in 5 places is unwarranted. I also feel there's a nonzero supply chain risk in it for such a heavily used project such as redis-py. (One could also argue that it's more cost-effective bandwidth-wise, and better for the environment to not have the world necessarily download those extra dependencies some million times per day...)

As for the expressiveness, if you're thinking about e.g. introspecting functions to see whether they're @deprecated, I don't think that really matters..?

For instance, Django happily just calls warnings.warn without a wrapper wherever they need to warn about a deprecation, á la https://github.com/django/django/blob/10bb21e71e3668f770493e2af0d0e0271830f7a3/django/db/models/expressions.py#L1551-L1561 ...

@akx akx force-pushed the remove-deprecated-dependency branch from 3592e04 to f8814da Compare September 28, 2022 12:11
@codecov-commenter
Copy link

codecov-commenter commented Sep 28, 2022

Codecov Report

Base: 92.17% // Head: 92.17% // No change to project coverage 👍

Coverage data is based on head (9fe8366) compared to base (9fe8366).
Patch has no changes to coverable lines.

❗ Current head 9fe8366 differs from pull request most recent head b9d88e0. Consider uploading reports for the commit b9d88e0 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2386   +/-   ##
=======================================
  Coverage   92.17%   92.17%           
=======================================
  Files         110      110           
  Lines       28924    28924           
=======================================
  Hits        26661    26661           
  Misses       2263     2263           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@akx akx force-pushed the remove-deprecated-dependency branch from f8814da to b9d88e0 Compare September 29, 2022 11:05
@akx akx force-pushed the remove-deprecated-dependency branch from b9d88e0 to 54f6294 Compare October 11, 2022 11:24
@akx
Copy link
Contributor Author

akx commented Oct 25, 2022

@chayim Have you had a chance to look at my comments above?

@chayim
Copy link
Contributor

chayim commented Oct 26, 2022

@akx I'm more than happy to reduce any (and frankly all) dependencies. I'd like to hard reduce them in general, and keep things tidy. However, I'd like to maintain deprecation as a decorated interface, rather than an in-function call.

The differences may be minor, but I believe it improves readability, which is something we generally need to improve.

I'm VERY pro removing the dependency. However, that merge would be contingent on a decorator providing the same functionality. Any chance you're interested in modifying your PR accordingly (pretty please!)?

@akx akx force-pushed the remove-deprecated-dependency branch 2 times, most recently from 6a8e187 to db0e772 Compare October 27, 2022 16:23
@akx
Copy link
Contributor Author

akx commented Oct 27, 2022

@chayim Sure, I added a deprecated_function decorator that does what deprecated did for functions. When single parameters may be deprecated in the future, the function would call warn_deprecated directly.

@chayim
Copy link
Contributor

chayim commented Oct 30, 2022

@dvora-h when you're cool with this... let's get it into the next milestone (this week!)?. Unfortunately @akx I can't review this due to timing. But, love that we're going down this path...

@chayim chayim requested a review from dvora-h October 30, 2022 07:45
@chayim chayim added the maintenance Maintenance (CI, Releases, etc) label Oct 30, 2022
@chayim chayim changed the title Remove deprecated dependency Supply chain risk reduction: remove dependency on library named deprecated Oct 30, 2022
@dvora-h
Copy link
Collaborator

dvora-h commented Oct 30, 2022

@akx LGTM!
Can you just add your decorator to the deprecated commands in SEARCH so the CI will pass? I added deprecation to them after you opened this PR...

No need for an external library just for 5 annotations.
@akx akx force-pushed the remove-deprecated-dependency branch from 39cc6ff to 4b0977a Compare October 30, 2022 11:05
@akx
Copy link
Contributor Author

akx commented Oct 30, 2022

@dvora-h Sure! Rebased & fixed search.

@dvora-h dvora-h merged commit 842634e into redis:master Oct 30, 2022
chayim pushed a commit that referenced this pull request Nov 21, 2022
No need for an external library just for 5 annotations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Maintenance (CI, Releases, etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants