Add typing for ConcurrencyManager and deprecate it.

Review Request #14044 — Created July 16, 2024 and submitted

Information

Djblets
release-6.x

Reviewers

This change adds generic parameters for ConcurrencyManager so it can be
used where we would expect a Manager.

This particular class also hasn't been useful since the very early days
of Django, since the base Manager.get_or_create implementation now does
exactly what this code does, preventing us from ever hitting the
exception handler. Because of that, I've removed the get_or_create
implementation entirely and marked the class as deprecated.

  • Ran unit tests.
Summary ID
Add typing for ConcurrencyManager and deprecate it.
This change adds generic parameters for `ConcurrencyManager` so it can be used where we would expect a Manager. This particular class also hasn't been useful since the very early days of Django, since the base `Manager.get_or_create` implementation now does exactly what this code does, preventing us from ever hitting the exception handler. Because of that, I've removed the `get_or_create` implementation entirely and marked the class as deprecated. Testing Done: Used with some other code.
6975e7645864bcb3cd0919f2069a68441e38c3df
Description From Last Updated

"Django"

chipx86chipx86

We should reference the function properly for the Django manager method., while we're fixing the docs. Can we also add …

chipx86chipx86

With Manager[_T_co], do we need Generic[...]? I think we inherit the generic nature from the former, given the TypeVar.

chipx86chipx86

I think we've been moving more to a two-release deprecation cycle for most things.

chipx86chipx86

Can we state that it wil be removed in 8.0?

chipx86chipx86
maubin
  1. Ship It!
  2. 
      
chipx86
  1. 
      
  2. djblets/db/managers.py (Diff revision 1)
     
     
    Show all issues

    "Django"

  3. djblets/db/managers.py (Diff revision 1)
     
     
    Show all issues

    We should reference the function properly for the Django manager method., while we're fixing the docs.

    Can we also add Args and Returns?

  4. djblets/db/managers.py (Diff revision 1)
     
     

    Huh, wait, why has this been working all this time? We should have noticed this.

    1. I just looked at the source for Django's get_or_create and they're doing this same thing internally now. I think we can just deprecate this entirely.

    2. Decided to dive in and I concur. Looks like the old logic we were working around existed in 0.95, but by 1.0 they implemented the first version of the equivalant of what this class does (wow, this is old). We probably can deprecate this.

  5. 
      
david
chipx86
  1. 
      
  2. djblets/db/managers.py (Diff revision 2)
     
     
     
     
    Show all issues

    With Manager[_T_co], do we need Generic[...]? I think we inherit the generic nature from the former, given the TypeVar.

  3. djblets/db/managers.py (Diff revision 2)
     
     
    Show all issues

    I think we've been moving more to a two-release deprecation cycle for most things.

  4. 
      
david
chipx86
  1. 
      
  2. djblets/db/managers.py (Diff revision 3)
     
     
    Show all issues

    Can we state that it wil be removed in 8.0?

  3. 
      
david
Review request changed
Status:
Completed
Change Summary:
Pushed to release-6.x (7e50db2)