Browse Source

ref: clean up sentry flake8 plugin (#33847)

* fix: Remove unused `# noqa` lint disable comments

* ref: clean up sentry flake8 plugin

- remove S005: pyupgrade handles this for us
- remove `pycodestyle` handling: flake8 does this natively
- clean up the ignore list and use extend-ignore
asottile-sentry 2 years ago
parent
commit
94c896a4a3

+ 1 - 1
bin/find-good-catalogs

@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 
-import json  # noqa: b317
+import json  # noqa: S003
 import os
 
 import click

+ 1 - 1
conftest.py

@@ -82,7 +82,7 @@ def pytest_runtest_makereport(item, call):
         except AttributeError:
             pass
 
-        print(_error_workflow_command(filesystempath, lineno, longrepr))  # noqa: B314
+        print(_error_workflow_command(filesystempath, lineno, longrepr))  # noqa: S002
 
 
 def _error_workflow_command(filesystempath, lineno, longrepr):

+ 1 - 1
scripts/appconnect_cli.py

@@ -39,7 +39,7 @@ def main(argv):
     elif argv[0] == "dump-db":
         # Dumps (part of) the AppConnectBuild table.
         for build in AppConnectBuild.objects.all():
-            print(  # noqa: B314
+            print(  # noqa: S002
                 f"{build!r} app_id={build.app_id} bundle_id={build.bundle_id} platform={build.platform} version={build.bundle_short_version} build={build.bundle_version} fetched={build.fetched}"
             )
 

+ 5 - 1
setup.cfg

@@ -2,12 +2,16 @@
 # File filtering is taken care of in pre-commit.
 # E203 false positive, see https://github.com/PyCQA/pycodestyle/issues/373
 # B011 We don't use PYTHONOPTIMIZE.
-ignore = F999,E203,E501,E128,E124,E402,W503,W504,E731,C901,B007,B009,B010,B011
 
 # XXX: E501 is ignored, which disables line length checking.
 # Currently, the black formatter doesn't wrap long strings: https://github.com/psf/black/issues/182#issuecomment-385325274
 # We already have a lot of E501's - these are lines black didn't wrap.
 # But rather than append # noqa: E501 to all of them, we just ignore E501 for now.
+extend-ignore = E203,E501,E402,E731,B007,B009,B010,B011
+
+per-file-ignores =
+    # allow prints in tests
+    tests/*: S002
 
 [flake8:local-plugins]
 paths = .

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

@@ -1,4 +1,4 @@
-from rest_framework.serializers import ListField  # NOQA
+from rest_framework.serializers import ListField
 
 
 class EmptyListField(ListField):

+ 1 - 1
src/sentry/app.py

@@ -23,6 +23,6 @@ from .nodestore import backend as nodestore  # NOQA
 from .quotas import backend as quotas  # NOQA
 from .ratelimits import backend as ratelimiter  # NOQA
 
-raven = client = RavenShim()  # NOQA
+raven = client = RavenShim()
 
 locks = LockManager(RedisLockBackend(redis.clusters.get("default")))

+ 1 - 1
src/sentry/audit_log/__init__.py

@@ -1,5 +1,5 @@
 from sentry.audit_log.manager import *  # NOQA
-from sentry.audit_log.register import default_manager  # NOQA
+from sentry.audit_log.register import default_manager
 
 # expose public api
 

+ 1 - 1
src/sentry/buffer/__init__.py

@@ -2,7 +2,7 @@ from django.conf import settings
 
 from sentry.utils.services import LazyServiceWrapper
 
-from .base import Buffer  # NOQA
+from .base import Buffer
 
 backend = LazyServiceWrapper(Buffer, settings.SENTRY_BUFFER, settings.SENTRY_BUFFER_OPTIONS)
 backend.expose(locals())

+ 1 - 1
src/sentry/buffer/redis.py

@@ -296,7 +296,7 @@ class RedisBuffer(Buffer):
             # XXX(py3): Note that ``import_string`` explicitly wants a str in
             # python2, so we'll decode (for python3) and then translate back to
             # a byte string (in python2) for import_string.
-            model = import_string(str(values.pop("m").decode("utf-8")))  # NOQA
+            model = import_string(str(values.pop("m").decode("utf-8")))
 
             if values["f"].startswith(b"{"):
                 filters = self._load_values(json.loads(values.pop("f").decode("utf-8")))

+ 1 - 1
src/sentry/charts/__init__.py

@@ -2,7 +2,7 @@ from django.conf import settings
 
 from sentry.utils.services import LazyServiceWrapper
 
-from .base import ChartRenderer  # NOQA
+from .base import ChartRenderer
 
 # The charts module provides a service to interface with the external
 # Chartcuterie service, which produces charts as images.

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