python: Clean up getattr, setattr, delattr calls with literal names.

These were useful as a transitional workaround to ignore type errors
that only show up with django-stubs, while avoiding errors about
unused type: ignore comments without django-stubs.  Now that the
django-stubs transition is complete, switch to type: ignore comments
so that mypy will tell us if they become unnecessary.  Many already
have.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2022-10-07 21:10:17 -07:00
committed by Tim Abbott
parent 5e1ebf2861
commit 1385a827c2
17 changed files with 50 additions and 55 deletions

View File

@@ -41,7 +41,7 @@ def transfer_avatars_to_s3(processes: int) -> None:
_transfer_avatar_to_s3(user)
else: # nocoverage
connection.close()
_cache = getattr(cache, "_cache")
_cache = cache._cache # type: ignore[attr-defined] # not in stubs
assert isinstance(_cache, bmemcached.Client)
_cache.disconnect_all()
with ProcessPoolExecutor(max_workers=processes) as executor:
@@ -76,7 +76,7 @@ def transfer_message_files_to_s3(processes: int) -> None:
_transfer_message_files_to_s3(attachment)
else: # nocoverage
connection.close()
_cache = getattr(cache, "_cache")
_cache = cache._cache # type: ignore[attr-defined] # not in stubs
assert isinstance(_cache, bmemcached.Client)
_cache.disconnect_all()
with ProcessPoolExecutor(max_workers=processes) as executor:
@@ -111,7 +111,7 @@ def transfer_emoji_to_s3(processes: int) -> None:
_transfer_emoji_to_s3(realm_emoji)
else: # nocoverage
connection.close()
_cache = getattr(cache, "_cache")
_cache = cache._cache # type: ignore[attr-defined] # not in stubs
assert isinstance(_cache, bmemcached.Client)
_cache.disconnect_all()
with ProcessPoolExecutor(max_workers=processes) as executor: