Browse Source

feat: Upgrade sentry-flake8 to 0.1.x

David Cramer 5 years ago
parent
commit
b7bd2528da

+ 2 - 2
requirements-dev.txt

@@ -5,8 +5,8 @@ Babel
 # https://github.com/jaraco/configparser/issues/27
 # https://github.com/jaraco/configparser/issues/30
 configparser!=3.5.2,!=3.5.3,!=3.7.0
+docker>=3.7.0,<3.8.0
 flake8>=3.5.0,<3.6.0
 isort>=4.3.4,<4.4.0
 pycodestyle>=2.3.1,<2.4.0
-sentry-flake8>=0.0.1
-docker>=3.7.0,<3.8.0
+sentry-flake8>=0.1.0,<0.2.0

+ 1 - 1
setup.cfg

@@ -8,7 +8,7 @@ markers =
     snuba: mark a test as requiring snuba
 
 [flake8]
-ignore = F999,E501,E128,E124,E402,W503,E731,C901
+ignore = F999,E501,E128,E124,E402,W503,E731,C901,B007,B306,B009,B010
 max-line-length = 100
 exclude = .venv/.git,*/south_migrations/*,node_modules/*,src/sentry/static/sentry/vendor/*,docs/*,src/south/*,examples/*
 

+ 2 - 2
src/debug_toolbar/panels/profiling.py

@@ -26,7 +26,7 @@ class DjangoDebugToolbarStats(Stats):
 
 
 class FunctionCall(object):
-    def __init__(self, statobj, func, depth=0, stats=None, id=0, parent_ids=[], hsv=(0, 0.5, 1)):
+    def __init__(self, statobj, func, depth=0, stats=None, id=0, parent_ids=(), hsv=(0, 0.5, 1)):
         self.statobj = statobj
         self.func = func
         if stats:
@@ -88,7 +88,7 @@ class FunctionCall(object):
                 self.depth + 1,
                 stats=stats,
                 id=six.text_type(self.id) + '_' + six.text_type(i),
-                parent_ids=self.parent_ids + [self.id],
+                parent_ids=self.parent_ids + (self.id,),
                 hsv=(h1, s1, 1)
             )
 

+ 5 - 2
src/sentry/logging/handlers.py

@@ -61,11 +61,14 @@ class HumanRenderer(object):
 
 
 class StructLogHandler(logging.StreamHandler):
-    def emit(self, record, logger=get_logger()):
+    def emit(self, record, logger=None):
         # If anyone wants to use the 'extra' kwarg to provide context within
         # structlog, we have to strip all of the default attributes from
         # a record because the RootLogger will take the 'extra' dictionary
         # and just turn them into attributes.
+        if logger is None:
+            logger = get_logger()
+
         kwargs = {
             k: v for k, v in six.iteritems(vars(record)) if k not in throwaways and v is not None
         }
@@ -113,7 +116,7 @@ metrics_badchars_re = re.compile("[^a-z0-9_.]")
 
 
 class MetricsLogHandler(logging.Handler):
-    def emit(self, record, logger=get_logger()):
+    def emit(self, record, logger=None):
         """
         Turn something like:
             > django.request.Forbidden (CSRF cookie not set.): /account

+ 3 - 3
src/sentry/models/group.py

@@ -83,7 +83,7 @@ class EventOrdering(Enum):
 
 
 def get_oldest_or_latest_event_for_environments(
-        ordering, environments=[], issue_id=None, project_id=None):
+        ordering, environments=(), issue_id=None, project_id=None):
     from sentry.utils import snuba
     from sentry.models import SnubaEvent
 
@@ -410,7 +410,7 @@ class Group(Model):
                 self._latest_event = None
         return self._latest_event
 
-    def get_latest_event_for_environments(self, environments=[]):
+    def get_latest_event_for_environments(self, environments=()):
         use_snuba = options.get('snuba.events-queries.enabled')
 
         # Fetch without environment if Snuba is not enabled
@@ -439,7 +439,7 @@ class Group(Model):
                 self._oldest_event = None
         return self._oldest_event
 
-    def get_oldest_event_for_environments(self, environments=[]):
+    def get_oldest_event_for_environments(self, environments=()):
         use_snuba = options.get('snuba.events-queries.enabled')
 
         # Fetch without environment if Snuba is not enabled

+ 2 - 2
src/sentry/models/scheduledeletion.py

@@ -38,13 +38,13 @@ class ScheduledDeletion(Model):
         db_table = 'sentry_scheduleddeletion'
 
     @classmethod
-    def schedule(cls, instance, days=30, data={}, actor=None):
+    def schedule(cls, instance, days=30, data=None, actor=None):
         return cls.objects.create(
             app_label=instance._meta.app_label,
             model_name=type(instance).__name__,
             object_id=instance.pk,
             date_scheduled=timezone.now() + timedelta(days=days),
-            data=data,
+            data=data or {},
             actor_id=actor.id if actor else None,
         )
 

+ 2 - 2
src/sentry/pipeline/__init__.py

@@ -64,9 +64,9 @@ class NestedPipelineView(PipelineView):
     Useful for embedding an identity authentication pipeline.
     """
 
-    def __init__(self, bind_key, pipeline_cls, provider_key, config={}):
+    def __init__(self, bind_key, pipeline_cls, provider_key, config=None):
         self.provider_key = provider_key
-        self.config = config
+        self.config = config or {}
 
         class NestedPipeline(pipeline_cls):
             def set_parent_pipeline(self, parent_pipeline):

+ 1 - 1
src/sentry/utils/db.py

@@ -24,7 +24,7 @@ def is_postgres(alias='default'):
     return 'postgres' in engine
 
 
-def attach_foreignkey(objects, field, related=[], database=None):
+def attach_foreignkey(objects, field, related=(), database=None):
     """
     Shortcut method which handles a pythonic LEFT OUTER JOIN.
 

+ 1 - 1
tests/sentry/api/endpoints/test_project_details.py

@@ -713,7 +713,7 @@ class CopyProjectSettingsTest(APITestCase):
         for rule, other_rule in zip(rules, self.rules):
             assert rule.label == other_rule.label
 
-    def assert_settings_not_copied(self, project, teams=[]):
+    def assert_settings_not_copied(self, project, teams=()):
         for key in six.iterkeys(self.options_dict):
             assert project.get_option(key) is None
 

+ 1 - 1
tests/sentry/models/test_project.py

@@ -307,7 +307,7 @@ class CopyProjectSettingsTest(TestCase):
         for rule, other_rule in zip(rules, self.rules):
             assert rule.label == other_rule.label
 
-    def assert_settings_not_copied(self, project, teams=[]):
+    def assert_settings_not_copied(self, project, teams=()):
         for key in six.iterkeys(self.options_dict):
             assert project.get_option(key) is None