Skip to content

Commit 250138f

Browse files
authored
Cleaup python code/formatting (#472)
1 parent 7f816b4 commit 250138f

File tree

20 files changed

+57
-58
lines changed

20 files changed

+57
-58
lines changed

django_prometheus/cache/backends/memcached.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ def get(self, key, default=None, version=None):
2222
class PyLibMCCache(MemcachedPrometheusCacheMixin, memcached.PyLibMCCache):
2323
"""Inherit memcached to add metrics about hit/miss ratio"""
2424

25-
pass
26-
2725

2826
class PyMemcacheCache(MemcachedPrometheusCacheMixin, memcached.PyMemcacheCache):
2927
"""Inherit memcached to add metrics about hit/miss ratio"""
30-
31-
pass

django_prometheus/cache/backends/redis.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ def get(self, key, default=None, version=None, client=None):
2828
if cached is not None:
2929
django_cache_hits_total.labels(backend="redis").inc()
3030
return cached
31-
else:
32-
django_cache_misses_total.labels(backend="redis").inc()
33-
return default
31+
django_cache_misses_total.labels(backend="redis").inc()
32+
return default
3433

3534

3635
class NativeRedisCache(DjangoRedisCache):
@@ -44,6 +43,5 @@ def get(self, key, default=None, version=None):
4443
if result is not None:
4544
django_cache_hits_total.labels(backend="native_redis").inc()
4645
return result
47-
else:
48-
django_cache_misses_total.labels(backend="native_redis").inc()
49-
return default
46+
django_cache_misses_total.labels(backend="native_redis").inc()
47+
return default

django_prometheus/db/backends/mysql/base.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
class DatabaseFeatures(base.DatabaseFeatures):
77
"""Our database has the exact same features as the base one."""
88

9-
pass
10-
119

1210
class DatabaseWrapper(DatabaseWrapperMixin, base.DatabaseWrapper):
1311
CURSOR_CLASS = base.CursorWrapper

django_prometheus/db/backends/spatialite/base.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
class DatabaseFeatures(features.DatabaseFeatures):
88
"""Our database has the exact same features as the base one."""
99

10-
pass
11-
1210

1311
class DatabaseWrapper(DatabaseWrapperMixin, base.DatabaseWrapper):
1412
CURSOR_CLASS = sqlite_base.SQLiteCursorWrapper

django_prometheus/db/backends/sqlite3/base.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
class DatabaseFeatures(base.DatabaseFeatures):
77
"""Our database has the exact same features as the base one."""
88

9-
pass
10-
119

1210
class DatabaseWrapper(DatabaseWrapperMixin, base.DatabaseWrapper):
1311
CURSOR_CLASS = base.SQLiteCursorWrapper

django_prometheus/db/common.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ def ExportingCursorWrapper(cursor_class, alias, vendor):
5555
"""Returns a CursorWrapper class that knows its database's alias and
5656
vendor name.
5757
"""
58-
5958
labels = {"alias": alias, "vendor": vendor}
6059

6160
class CursorWrapper(cursor_class):

django_prometheus/migrations.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def ExportMigrations():
3131
This is meant to be called during app startup, ideally by
3232
django_prometheus.apps.AppConfig.
3333
"""
34-
3534
# Import MigrationExecutor lazily. MigrationExecutor checks at
3635
# import time that the apps are ready, and they are not when
3736
# django_prometheus is imported. ExportMigrations() should be

django_prometheus/tests/end2end/testapp/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040
"django.template.context_processors.request",
4141
"django.contrib.auth.context_processors.auth",
4242
"django.contrib.messages.context_processors.messages",
43-
]
43+
],
4444
},
45-
}
45+
},
4646
]
4747

4848
WSGI_APPLICATION = "testapp.wsgi.application"

django_prometheus/tests/end2end/testapp/test_caches.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,5 @@ def test_cache_version_support(self, supported_cache):
7070
tested_cache = caches[supported_cache]
7171
tested_cache.set("foo1", "bar v.1", version=1)
7272
tested_cache.set("foo1", "bar v.2", version=2)
73-
assert "bar v.1" == tested_cache.get("foo1", version=1)
74-
assert "bar v.2" == tested_cache.get("foo1", version=2)
73+
assert tested_cache.get("foo1", version=1) == "bar v.1"
74+
assert tested_cache.get("foo1", version=2) == "bar v.2"

django_prometheus/tests/end2end/testapp/test_db.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class TestDbMetrics(BaseDBTest):
3333

3434
def test_config_has_expected_databases(self):
3535
"""Not a real unit test: ensures that testapp.settings contains the
36-
databases this test expects."""
36+
databases this test expects.
37+
"""
3738
assert "default" in connections.databases.keys()
3839
assert "test_db_1" in connections.databases.keys()
3940
assert "test_db_2" in connections.databases.keys()

0 commit comments

Comments
 (0)