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

@@ -15,6 +15,6 @@ class Command(BaseCommand):
def handle(self, *args: Any, **options: Any) -> None:
assert settings.DEVELOPMENT
UserMessage.objects.all().update(flags=F("flags").bitand(~UserMessage.flags.read))
_cache = getattr(cache, "_cache")
_cache = cache._cache # type: ignore[attr-defined] # not in stubs
assert isinstance(_cache, bmemcached.Client)
_cache.flush_all()