Browse Source

ref: upgrade to flake8 6.1 (#57062)

depends on https://github.com/getsentry/getsentry/pull/11746
anthony sottile 1 year ago
parent
commit
808f610f97

+ 3 - 3
requirements-dev-frozen.txt

@@ -56,7 +56,7 @@ execnet==1.9.0
 fastjsonschema==2.16.2
 fido2==0.9.2
 filelock==3.7.0
-flake8==6.0.0
+flake8==6.1.0
 flake8-bugbear==22.10.27
 frozenlist==1.3.3
 google-api-core==2.12.0
@@ -128,11 +128,11 @@ psutil==5.9.2
 psycopg2-binary==2.8.6
 pyasn1==0.4.5
 pyasn1-modules==0.2.4
-pycodestyle==2.10.0
+pycodestyle==2.11.0
 pycountry==17.5.14
 pycparser==2.21
 pydantic==1.10.9
-pyflakes==3.0.1
+pyflakes==3.1.0
 pyjwt==2.4.0
 pyopenssl==23.0.0
 pyparsing==3.0.9

+ 1 - 1
requirements-dev.txt

@@ -20,7 +20,7 @@ sentry-cli>=2.16.0
 # pre-commit dependencies
 pre-commit>=3.3
 black>=22.10.0
-flake8>=6
+flake8>=6.1
 flake8-bugbear>=22.10
 pyupgrade>=3.2.3
 isort>=5.10.1

+ 3 - 3
src/bitfield/models.py

@@ -41,13 +41,13 @@ class BitFieldFlags:
             yield Bit(self._flags.index(flag))
 
     def items(self):
-        return list(self.iteritems())  # NOQA
+        return list(self.iteritems())
 
     def keys(self):
-        return list(self.iterkeys())  # NOQA
+        return list(self.iterkeys())
 
     def values(self):
-        return list(self.itervalues())  # NOQA
+        return list(self.itervalues())
 
 
 class BitFieldCreator:

+ 2 - 2
src/bitfield/types.py

@@ -195,7 +195,7 @@ class BitHandler:
     __setitem__ = __setattr__
 
     def __iter__(self):
-        return self.iteritems()  # NOQA
+        return self.iteritems()
 
     def __sentry__(self):
         return repr(self)
@@ -227,7 +227,7 @@ class BitHandler:
         return iter(self._keys)
 
     def items(self):
-        return list(self.iteritems())  # NOQA
+        return list(self.iteritems())
 
     def iteritems(self):
         for k in self._keys:

+ 1 - 1
src/sentry/api/endpoints/user_authenticator_details.py

@@ -31,7 +31,7 @@ class UserAuthenticatorDetailsEndpoint(UserEndpoint):
         devices = authenticator.config
         for device in devices["devices"]:
             # this is for devices registered with webauthn, since the stored data is not a string, we need to decode it
-            if type(device["binding"]) == AuthenticatorData:
+            if isinstance(device["binding"], AuthenticatorData):
                 if decode_credential_id(device) == interface_device_id:
                     return device
             elif device["binding"]["keyHandle"] == interface_device_id:

+ 1 - 1
src/sentry/api/serializers/rest_framework/doc_integration.py

@@ -27,7 +27,7 @@ class MetadataField(serializers.JSONField):
         try:
             validated_data = validate_metadata_schema(data)
         except SchemaValidationError as e:
-            raise ValidationError(e.message)  # noqa: B306
+            raise ValidationError(e.message)
 
         return validated_data
 

+ 1 - 1
src/sentry/api/serializers/rest_framework/sentry_app.py

@@ -53,7 +53,7 @@ class SchemaField(serializers.Field):
         try:
             validate_ui_element_schema(data)
         except SchemaValidationError as e:
-            raise ValidationError(e.message)  # noqa: B306
+            raise ValidationError(e.message)
 
         return data
 

+ 1 - 3
src/sentry/api/validators/sentry_apps/schema.py

@@ -235,9 +235,7 @@ def check_each_element_for_error(instance):
             validate_component(element)
         except SchemaValidationError as e:
             # catch the validation error and re-write the error so the user knows which element has the issue
-            raise SchemaValidationError(
-                f"{e.message} for element of type '{found_type}'"  # noqa: B306
-            )
+            raise SchemaValidationError(f"{e.message} for element of type '{found_type}'")
 
 
 def validate_text_component_defaults(element, found_type):

+ 1 - 1
src/sentry/apidocs/spectacular_ports.py

@@ -145,7 +145,7 @@ def resolve_type_hint(hint) -> Any:
             required=[h for h in hint.__required_keys__ if h not in excluded_fields],
         )
     elif origin is Union:
-        type_args = [arg for arg in args if arg is not type(None)]  # noqa: E721
+        type_args = [arg for arg in args if arg is not type(None)]
         if len(type_args) > 1:
             schema = {"oneOf": [resolve_type_hint(arg) for arg in type_args]}
         else:

+ 5 - 5
src/sentry/auth/authenticators/u2f.py

@@ -85,7 +85,7 @@ class U2fInterface(AuthenticatorInterface):
 
     def _get_kept_devices(self, key):
         def _key_does_not_match(device):
-            if type(device["binding"]) == AuthenticatorData:
+            if isinstance(device["binding"], AuthenticatorData):
                 return decode_credential_id(device) != key
             else:
                 return device["binding"]["keyHandle"] != key
@@ -116,7 +116,7 @@ class U2fInterface(AuthenticatorInterface):
             # XXX: The previous version of python-u2flib-server didn't store
             # the `version` in the device binding. Defaulting to `U2F_V2` here
             # so that we don't break existing u2f registrations.
-            if type(data["binding"]) == AuthenticatorData:
+            if isinstance(data["binding"], AuthenticatorData):
                 rv.append(data["binding"])
             else:
                 data["binding"].setdefault("version", "U2F_V2")
@@ -129,7 +129,7 @@ class U2fInterface(AuthenticatorInterface):
         # AuthenticatorData are those from WebAuthn registered devices that we don't have to modify
         # the other is those registered with u2f-api and it a dict with the keys keyHandle and publicKey
         for device in self.get_u2f_devices():
-            if type(device) == AuthenticatorData:
+            if isinstance(device, AuthenticatorData):
                 credentials.append(device.credential_data)
             else:
                 credentials.append(create_credential_object(device))
@@ -148,7 +148,7 @@ class U2fInterface(AuthenticatorInterface):
 
     def get_device_name(self, key):
         for device in self.config.get("devices", ()):
-            if type(device["binding"]) == AuthenticatorData:
+            if isinstance(device["binding"], AuthenticatorData):
                 if decode_credential_id(device) == key:
                     return device["name"]
             elif device["binding"]["keyHandle"] == key:
@@ -157,7 +157,7 @@ class U2fInterface(AuthenticatorInterface):
     def get_registered_devices(self):
         rv = []
         for device in self.config.get("devices", ()):
-            if type(device["binding"]) == AuthenticatorData:
+            if isinstance(device["binding"], AuthenticatorData):
                 rv.append(
                     {
                         "timestamp": to_datetime(device["ts"]),

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