Skip to content

Commit

Permalink
Fixing linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Carl Crowder committed May 15, 2023
1 parent 1bf1481 commit 82f64c6
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 45 deletions.
2 changes: 1 addition & 1 deletion pylint_django/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pylint_django import plugin

if sys.version_info < (3,):
raise DeprecationWarning("Version 0.11.1 was the last to support Python 2. " "Please migrate to Python 3!")
raise DeprecationWarning("Version 0.11.1 was the last to support Python 2. Please migrate to Python 3!")

register = plugin.register # pylint: disable=invalid-name
load_configuration = plugin.load_configuration # pylint: disable=invalid-name
19 changes: 3 additions & 16 deletions pylint_django/augmentations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,10 @@
from django import VERSION as django_version
from django.utils import termcolors
from django.views.generic.base import ContextMixin, RedirectView, View
from django.views.generic.dates import (
DateMixin,
DayMixin,
MonthMixin,
WeekMixin,
YearMixin,
)
from django.views.generic.detail import (
SingleObjectMixin,
SingleObjectTemplateResponseMixin,
TemplateResponseMixin,
)
from django.views.generic.dates import DateMixin, DayMixin, MonthMixin, WeekMixin, YearMixin
from django.views.generic.detail import SingleObjectMixin, SingleObjectTemplateResponseMixin, TemplateResponseMixin
from django.views.generic.edit import DeletionMixin, FormMixin, ModelFormMixin
from django.views.generic.list import (
MultipleObjectMixin,
MultipleObjectTemplateResponseMixin,
)
from django.views.generic.list import MultipleObjectMixin, MultipleObjectTemplateResponseMixin
from pylint.checkers.base import DocStringChecker, NameChecker
from pylint.checkers.classes import ClassChecker
from pylint.checkers.design_analysis import MisdesignChecker
Expand Down
21 changes: 5 additions & 16 deletions pylint_django/checkers/foreign_key_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,15 @@ def open(self):
# state is stashed in this property.

try:
from django.core.exceptions import ( # pylint: disable=import-outside-toplevel
ImproperlyConfigured,
)
from django.core.exceptions import ImproperlyConfigured # pylint: disable=import-outside-toplevel
except ModuleNotFoundError:
return

try:
import django # pylint: disable=import-outside-toplevel

django.setup()
from django.apps import ( # noqa pylint: disable=import-outside-toplevel,unused-import
apps,
)
from django.apps import apps # noqa pylint: disable=import-outside-toplevel,unused-import

# flake8: noqa=F401, F403
except ImproperlyConfigured:
Expand All @@ -103,19 +99,14 @@ def open(self):
# we will warn the user that they haven't actually configured Django themselves
self._raise_warning = True
# but use django defaults then...
from django.conf import ( # pylint: disable=import-outside-toplevel
settings,
)
from django.conf import settings # pylint: disable=import-outside-toplevel

settings.configure()
django.setup()
else:
# see if we can load the provided settings module
try:
from django.conf import ( # pylint: disable=import-outside-toplevel
Settings,
settings,
)
from django.conf import Settings, settings # pylint: disable=import-outside-toplevel

settings.configure(Settings(self.config.django_settings_module))
django.setup()
Expand All @@ -127,9 +118,7 @@ def open(self):
args=self.config.django_settings_module,
)
# however we'll trundle on with basic settings
from django.conf import ( # pylint: disable=import-outside-toplevel
settings,
)
from django.conf import settings # pylint: disable=import-outside-toplevel

settings.configure()
django.setup()
Expand Down
1 change: 0 additions & 1 deletion pylint_django/tests/input/func_noerror_form_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@


class ManyFieldsForm(forms.Form):

booleanfield = forms.BooleanField()
charfield = forms.CharField(max_length=40, null=True)
datetimefield = forms.DateTimeField(auto_now_add=True)
Expand Down
1 change: 0 additions & 1 deletion pylint_django/tests/input/func_noerror_forms_py33.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class Meta:


class TestFormWidgetAssignment(forms.Form):

multi_field = forms.MultipleChoiceField(choices=[("1", "First"), ("2", "Second")])

class Meta:
Expand Down
1 change: 0 additions & 1 deletion pylint_django/tests/input/func_noerror_model_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@


class LotsOfFieldsModel(models.Model):

bigintegerfield = models.BigIntegerField()
booleanfield = models.BooleanField(default=True)
charfield = models.CharField(max_length=40, null=True)
Expand Down
1 change: 0 additions & 1 deletion pylint_django/tests/input/migrations/0002_new_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@


class Migration(migrations.Migration):

dependencies = [
("input", "0001_noerror_initial"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ def forwards_test(apps, schema_editor):


class Migration(migrations.Migration):

operations = [
migrations.RunPython(), # [missing-backwards-migration-callable]
migrations.RunPython(forwards_test), # [missing-backwards-migration-callable]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def backwards_test(apps, schema_editor):


class Migration(migrations.Migration):

operations = [
migrations.RunPython(forwards_test, backwards_test),
migrations.RunPython(forwards_test, reverse_code=backwards_test),
Expand Down
1 change: 0 additions & 1 deletion pylint_django/transforms/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def is_model_or_form_field(cls):


def apply_type_shim(cls, _context=None): # noqa

if cls.name in _STR_FIELDS:
base_nodes = scoped_nodes.builtin_lookup("str")
elif cls.name in _INT_FIELDS:
Expand Down
4 changes: 1 addition & 3 deletions pylint_django/transforms/foreignkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ def _module_name_from_django_model_resolution(model_name, module_name):


def infer_key_classes(node, context=None):
from django.core.exceptions import ( # pylint: disable=import-outside-toplevel
ImproperlyConfigured,
)
from django.core.exceptions import ImproperlyConfigured # pylint: disable=import-outside-toplevel

keyword_args = []
if node.keywords:
Expand Down
7 changes: 5 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ requires =
commands =
django_not_installed: bash pylint_django/tests/test_django_not_installed.sh
django_is_installed: pylint --rcfile=tox.ini --load-plugins=pylint_django --disable=E5110 setup.py
flake8: flake8
pylint: pylint --rcfile=tox.ini -d missing-docstring,too-many-branches,too-many-return-statements,too-many-ancestors,fixme --ignore=tests pylint_django setup
flake8: flake8 pylint_django/
pylint: pylint --rcfile=tox.ini -d missing-docstring,too-many-branches,too-many-return-statements,too-many-ancestors,fixme --ignore=tests pylint_django
readme: bash -c "poetry build && twine check dist/*"
py{37,38,39,310,311}-django{22,30,31,32,40,41,42}: coverage run pylint_django/tests/test_func.py -v
clean: find . -type f -name '*.pyc' -delete
Expand Down Expand Up @@ -56,5 +56,8 @@ allowlist_externals =
[flake8]
max-line-length = 120

[pylint]
max-line-length = 120

[FORMAT]
max-line-length=120

0 comments on commit 82f64c6

Please sign in to comment.