Browse Source

ref(pyupgrade): remove six, partition 4 (#23705)

josh 4 years ago
parent
commit
5935b6ac81

+ 1 - 2
src/sentry/analytics/base.py

@@ -1,6 +1,5 @@
 __all__ = ("Analytics",)
 
-import six
 
 from sentry.analytics.event import Event
 from sentry.utils.services import Service
@@ -18,7 +17,7 @@ class Analytics(Service):
         >>> record(Event())
         >>> record('organization.created', organization)
         """
-        if isinstance(event_or_event_type, six.string_types):
+        if isinstance(event_or_event_type, str):
             event = self.event_manager.get(event_or_event_type).from_instance(instance, **kwargs)
         elif isinstance(event_or_event_type, Event):
             event = event_or_event_type.from_instance(instance, **kwargs)

+ 3 - 6
src/sentry/analytics/event.py

@@ -2,7 +2,6 @@ from sentry.utils.compat import map
 
 __all__ = ("Attribute", "Event", "Map")
 
-import six
 from uuid import uuid1
 from base64 import b64encode
 
@@ -13,7 +12,7 @@ from sentry.utils.dates import to_timestamp
 
 
 class Attribute:
-    def __init__(self, name, type=six.text_type, required=True):
+    def __init__(self, name, type=str, required=True):
         self.name = name
         self.type = type
         self.required = required
@@ -60,9 +59,7 @@ class Map(Attribute):
             data[attr.name] = attr.extract(nv)
 
         if items:
-            raise ValueError(
-                "Unknown attributes: {}".format(", ".join(map(six.text_type, six.iterkeys(items))))
-            )
+            raise ValueError("Unknown attributes: {}".format(", ".join(map(str, items.keys()))))
 
         return data
 
@@ -92,7 +89,7 @@ class Event:
             data[attr.name] = attr.extract(nv)
 
         if items:
-            raise ValueError("Unknown attributes: {}".format(", ".join(six.iterkeys(items))))
+            raise ValueError("Unknown attributes: {}".format(", ".join(items.keys())))
 
         self.data = data
 

+ 1 - 3
src/sentry/auth/authenticators/__init__.py

@@ -1,5 +1,3 @@
-import six
-
 from .base import AuthenticatorInterface  # NOQA
 from .sms import SmsInterface
 from .recovery_code import RecoveryCodeInterface
@@ -19,7 +17,7 @@ def register_authenticator(cls):
 
 
 def available_authenticators(ignore_backup=False):
-    interfaces = six.itervalues(AUTHENTICATOR_INTERFACES)
+    interfaces = AUTHENTICATOR_INTERFACES.values()
     if not ignore_backup:
         return [v for v in interfaces if v.is_available]
     return [v for v in interfaces if not v.is_backup_interface and v.is_available]

+ 2 - 8
src/sentry/auth/authenticators/base.py

@@ -1,5 +1,3 @@
-import six
-
 from django.core.cache import cache
 from django.utils.translation import ugettext_lazy as _
 
@@ -53,18 +51,14 @@ class AuthenticatorInterface:
         """If the interface has an activation method that needs to be
         called this returns `True`.
         """
-        return self.activate.__func__ is not six.get_unbound_function(
-            AuthenticatorInterface.activate
-        )
+        return self.activate.__func__ is not AuthenticatorInterface.activate
 
     @property
     def can_validate_otp(self):
         """If the interface is able to validate OTP codes then this returns
         `True`.
         """
-        return self.validate_otp.__func__ is not six.get_unbound_function(
-            AuthenticatorInterface.validate_otp
-        )
+        return self.validate_otp.__func__ is not AuthenticatorInterface.validate_otp
 
     @property
     def config(self):

+ 1 - 2
src/sentry/auth/helper.py

@@ -2,7 +2,6 @@ import logging
 
 from uuid import uuid4
 
-import six
 from django.conf import settings
 from django.contrib import messages
 from django.core.urlresolvers import reverse
@@ -651,7 +650,7 @@ class AuthHelper:
         try:
             identity = self.provider.build_identity(data)
         except IdentityNotValid as error:
-            return self.error(six.text_type(error) or ERR_INVALID_IDENTITY)
+            return self.error(str(error) or ERR_INVALID_IDENTITY)
 
         if self.state.flow == self.FLOW_LOGIN:
             # create identity and authenticate the user

+ 1 - 2
src/sentry/auth/manager.py

@@ -1,6 +1,5 @@
 __all__ = ["ProviderManager"]
 
-import six
 
 from .exceptions import ProviderNotRegistered
 
@@ -12,7 +11,7 @@ class ProviderManager:
         self.__values = {}
 
     def __iter__(self):
-        return six.iteritems(self.__values)
+        yield from self.__values.items()
 
     def get(self, key, **kwargs):
         try:

+ 1 - 2
src/sentry/auth/password_validation.py

@@ -2,7 +2,6 @@ from django.conf import settings
 from django.core.exceptions import ImproperlyConfigured, ValidationError
 from django.utils.functional import lazy
 from django.utils.html import format_html
-from django.utils.six import text_type
 from django.utils.translation import ugettext as _, ungettext
 
 from sentry.utils.imports import import_string
@@ -71,7 +70,7 @@ def _password_validators_help_text_html(password_validators=None):
     return "<ul>%s</ul>" % "".join(help_items) if help_items else ""
 
 
-password_validators_help_text_html = lazy(_password_validators_help_text_html, text_type)
+password_validators_help_text_html = lazy(_password_validators_help_text_html, str)
 
 
 class MinimumLengthValidator:

+ 3 - 4
src/sentry/auth/providers/github/client.py

@@ -1,4 +1,3 @@
-import six
 from requests.exceptions import RequestException
 from sentry import http
 from sentry.utils import json
@@ -26,7 +25,7 @@ class GitHubClient:
                 headers=headers,
             )
         except RequestException as e:
-            raise GitHubApiError(six.text_type(e), status=getattr(e, "status_code", 0))
+            raise GitHubApiError(str(e), status=getattr(e, "status_code", 0))
         if req.status_code < 200 or req.status_code >= 300:
             raise GitHubApiError(req.content, status=req.status_code)
         return json.loads(req.content)
@@ -41,8 +40,8 @@ class GitHubClient:
         return self._request("/user/emails")
 
     def is_org_member(self, org_id):
-        org_id = six.text_type(org_id)
+        org_id = str(org_id)
         for o in self.get_org_list():
-            if six.text_type(o["id"]) == org_id:
+            if str(o["id"]) == org_id:
                 return True
         return False

+ 1 - 2
src/sentry/auth/providers/github/views.py

@@ -1,4 +1,3 @@
-import six
 from django import forms
 from sentry.auth.view import AuthView, ConfigureView
 from sentry.models import AuthIdentity
@@ -121,7 +120,7 @@ class SelectOrganization(AuthView):
         form = SelectOrganizationForm(org_list, request.POST or None)
         if form.is_valid():
             org_id = form.cleaned_data["org"]
-            org = [o for o in org_list if org_id == six.text_type(o["id"])][0]
+            org = [o for o in org_list if org_id == str(o["id"])][0]
             helper.bind_state("org", org)
             return helper.next_step()
 

+ 1 - 1
src/sentry/auth/providers/oauth2.py

@@ -1,6 +1,6 @@
 import logging
 
-from six.moves.urllib.parse import parse_qsl, urlencode
+from urllib.parse import parse_qsl, urlencode
 from time import time
 from uuid import uuid4
 

Some files were not shown because too many files changed in this diff