Skip to content

Commit 355faa2

Browse files
committed
fix static analysis issues
1 parent da54434 commit 355faa2

File tree

9 files changed

+34
-18
lines changed

9 files changed

+34
-18
lines changed

django_enum/drf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def to_internal_value(self, data: Any) -> Union[Enum, Any]:
168168
return self.primitive_field.to_internal_value(data)
169169
return data
170170

171-
def to_representation( # pylint: disable=R0201
171+
def to_representation(
172172
self, value: Any
173173
) -> Any:
174174
"""

django_enum/fields.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
NonStrictSelect,
4646
NonStrictSelectMultiple,
4747
)
48-
from django_enum.query import ( # HasAllFlagsExtraBigLookup,; HasAnyFlagsExtraBigLookup
48+
from django_enum.query import ( # HasAllFlagsExtraBigLookup,
4949
HasAllFlagsLookup,
5050
HasAnyFlagsLookup,
5151
)
@@ -807,10 +807,10 @@ def __init__(
807807
if self.enum:
808808
kwargs.setdefault(
809809
'max_length',
810-
max([
810+
max((
811811
len(self._coerce_to_value_type(choice[0]) or '')
812812
for choice in kwargs.get('choices', choices(enum))
813-
])
813+
))
814814
)
815815
super().__init__(enum=enum, primitive=primitive, **kwargs)
816816

django_enum/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def __init__(
310310
*,
311311
empty_value: Any = _Unspecified,
312312
strict: bool = ChoiceFieldMixin._strict_,
313-
empty_values: List[Any] = TypedChoiceField.empty_values,
313+
empty_values: Union[List[Any], Type[_Unspecified]] = _Unspecified,
314314
choices: Iterable[Tuple[Any, str]] = (),
315315
**kwargs
316316
):

django_enum/query.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,19 @@ def get_rhs_op(self, connection, rhs):
5050
# HasAllFlagsLookup
5151
# ): # pylint: disable=W0223
5252
# """
53-
# Support for bitwise has_all lookup on extra big integers (>64 bits) stored
54-
# as binary columns.
53+
# Support for bitwise has_all lookup on extra big integers (>64 bits)
54+
# stored as binary columns.
5555
#
5656
# get_bit(, 0) AND get_bit(, 7) = 1;
5757
# """
5858
#
5959
# def process_lhs(self, compiler, connection, lhs=None):
60-
# lhs_sql, lhs_params = Exact.process_lhs(self, compiler, connection, lhs)
60+
# lhs_sql, lhs_params = Exact.process_lhs(
61+
# self,
62+
# compiler,
63+
# connection,
64+
# lhs
65+
# )
6166
# rhs_sql, rhs_params = Exact.process_rhs(self, compiler, connection)
6267
# bits = get_set_bits(rhs_params[0])
6368
# if self.rhs:
@@ -97,12 +102,17 @@ def get_rhs_op(self, connection, rhs):
97102
# HasAnyFlagsLookup
98103
# ): # pylint: disable=W0223
99104
# """
100-
# Support for bitwise has_any lookup on extra big integers (>64 bits) stored
101-
# as binary columns.
105+
# Support for bitwise has_any lookup on extra big integers (>64 bits)
106+
# stored as binary columns.
102107
# """
103108
#
104109
# def process_lhs(self, compiler, connection, lhs=None):
105-
# lhs_sql, lhs_params = Exact.process_lhs(self, compiler, connection, lhs)
110+
# lhs_sql, lhs_params = Exact.process_lhs(
111+
# self,
112+
# compiler,
113+
# connection,
114+
# lhs
115+
# )
106116
# rhs_sql, rhs_params = Exact.process_rhs(self, compiler, connection)
107117
# bits = get_set_bits(rhs_params[0])
108118
# if self.rhs:

django_enum/tests/benchmarks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from django.db import connection
1111
from django.db.models import Q
12-
from django.test import TestCase, override_settings, SimpleTestCase
12+
from django.test import SimpleTestCase, TestCase, override_settings
1313
from django.test.utils import CaptureQueriesContext
1414
from django_enum.tests.benchmark import enums as benchmark_enums
1515
from django_enum.tests.benchmark import models as benchmark_models

django_enum/tests/djenum/migrations/0001_initial.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Generated by Django 4.2.4 on 2023-10-02 16:10
22

33
import datetime
4+
import pathlib
45
from decimal import Decimal
5-
from django.db import migrations, models
6+
67
import django_enum.fields
78
import django_enum.tests.djenum.enums
8-
import pathlib
9+
from django.db import migrations, models
910

1011

1112
class Migration(migrations.Migration):

django_enum/tests/enum_prop/admin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
try:
22
from django.contrib import admin
3-
from django_enum.tests.enum_prop.models import BitFieldModel, AdminDisplayBug35, EnumTester
3+
from django_enum.tests.enum_prop.models import (
4+
AdminDisplayBug35,
5+
BitFieldModel,
6+
EnumTester,
7+
)
48

59
class AdminDisplayBug35Admin(admin.ModelAdmin):
610

django_enum/tests/enum_prop/migrations/0001_initial.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
import datetime
44
from decimal import Decimal
5-
from django.db import migrations, models
5+
66
import django_enum.fields
7+
from django.db import migrations, models
78

89

910
class Migration(migrations.Migration):

django_enum/tests/tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
from django.db.models import Count, F, Func, OuterRef, Q, Subquery
1515
from django.db.utils import DatabaseError
1616
from django.http import QueryDict
17-
from django.test.utils import CaptureQueriesContext
1817
from django.test import Client, LiveServerTestCase, TestCase
18+
from django.test.utils import CaptureQueriesContext
1919
from django.urls import reverse
2020
from django.utils.functional import classproperty
2121
from django_enum import EnumField, TextChoices
@@ -3034,10 +3034,10 @@ def test_unsupported_flags(self):
30343034
)
30353035
from django_enum.tests.enum_prop.forms import EnumTesterForm
30363036
from django_enum.tests.enum_prop.models import (
3037+
AdminDisplayBug35,
30373038
BitFieldModel,
30383039
EnumFlagPropTester,
30393040
EnumFlagPropTesterRelated,
3040-
AdminDisplayBug35,
30413041
EnumTester,
30423042
MyModel,
30433043
)

0 commit comments

Comments
 (0)