flake8 fixes

fix_request_path_info
Diederik van der Boor 2016-12-19 11:28:41 +01:00
parent 3170ea95c2
commit 4aa3355f5c
10 changed files with 30 additions and 27 deletions

View File

@ -6,12 +6,13 @@ Copyright:
This code and affiliated files are (C) by Bert Constantin and individual contributors. This code and affiliated files are (C) by Bert Constantin and individual contributors.
Please see LICENSE and AUTHORS for more information. Please see LICENSE and AUTHORS for more information.
""" """
import django
# See PEP 440 (https://www.python.org/dev/peps/pep-0440/) # See PEP 440 (https://www.python.org/dev/peps/pep-0440/)
__version__ = "1.0.2" __version__ = "1.0.2"
# Monkey-patch Django < 1.5 to allow ContentTypes for proxy models. # Monkey-patch Django < 1.5 to allow ContentTypes for proxy models.
import django
if django.VERSION[:2] < (1, 5): if django.VERSION[:2] < (1, 5):
from django.contrib.contenttypes.models import ContentTypeManager from django.contrib.contenttypes.models import ContentTypeManager
from django.utils.encoding import smart_text from django.utils.encoding import smart_text

View File

@ -41,6 +41,7 @@ __all__ = (
'PolymorphicInlineAdminFormSet', 'PolymorphicInlineAdminFormSet',
'PolymorphicInlineSupportMixin', 'PolymorphicInlineSupportMixin',
'PolymorphicInlineModelAdmin', 'PolymorphicInlineModelAdmin',
'StackedPolymorphicInline',
'GenericPolymorphicInlineModelAdmin', 'GenericPolymorphicInlineModelAdmin',
'GenericStackedPolymorphicInline', 'GenericStackedPolymorphicInline',
) )

View File

@ -29,7 +29,7 @@ def transmogrify(cls, obj):
""" """
Upcast a class to a different type without asking questions. Upcast a class to a different type without asking questions.
""" """
if not '__init__' in obj.__dict__: if '__init__' not in obj.__dict__:
# Just assign __class__ to a different value. # Just assign __class__ to a different value.
new = obj new = obj
new.__class__ = cls new.__class__ = cls
@ -317,7 +317,7 @@ class PolymorphicQuerySet(QuerySet):
ordered_id_list.append(base_object.pk) ordered_id_list.append(base_object.pk)
# check if id of the result object occurres more than once - this can happen e.g. with base_objects.extra(tables=...) # check if id of the result object occurres more than once - this can happen e.g. with base_objects.extra(tables=...)
if not base_object.pk in base_result_objects_by_id: if base_object.pk not in base_result_objects_by_id:
base_result_objects_by_id[base_object.pk] = base_object base_result_objects_by_id[base_object.pk] = base_object
if base_object.polymorphic_ctype_id == self_model_class_id: if base_object.polymorphic_ctype_id == self_model_class_id:

View File

@ -6,6 +6,7 @@ from __future__ import absolute_import
import copy import copy
import django import django
from functools import reduce
from django.db import models from django.db import models
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.db.models import Q, FieldDoesNotExist from django.db.models import Q, FieldDoesNotExist
@ -26,9 +27,6 @@ else:
REL_FIELD_CLASSES = (RelatedField, ForeignObjectRel) REL_FIELD_CLASSES = (RelatedField, ForeignObjectRel)
from functools import reduce
################################################################################### ###################################################################################
# PolymorphicQuerySet support functions # PolymorphicQuerySet support functions
@ -128,7 +126,7 @@ def _translate_polymorphic_filter_definition(queryset_model, field_path, field_v
return _create_model_filter_Q(field_val, using=using) return _create_model_filter_Q(field_val, using=using)
elif field_path == 'not_instance_of': elif field_path == 'not_instance_of':
return _create_model_filter_Q(field_val, not_instance_of=True, using=using) return _create_model_filter_Q(field_val, not_instance_of=True, using=using)
elif not '___' in field_path: elif '___' not in field_path:
return None # no change return None # no change
# filter expression contains '___' (i.e. filter for polymorphic field) # filter expression contains '___' (i.e. filter for polymorphic field)

View File

@ -136,7 +136,7 @@ class ShowFieldBase(object):
if (self.polymorphic_showfield_max_line_width if (self.polymorphic_showfield_max_line_width
and xpos + len(p) > self.polymorphic_showfield_max_line_width and xpos + len(p) > self.polymorphic_showfield_max_line_width
and possible_line_break_pos != None): and possible_line_break_pos is not None):
rest = out[possible_line_break_pos:] rest = out[possible_line_break_pos:]
out = out[:possible_line_break_pos] out = out[:possible_line_break_pos]
out += '\n' + indentstr + rest out += '\n' + indentstr + rest

View File

@ -6,17 +6,10 @@ from __future__ import print_function
import uuid import uuid
import re import re
import django import django
try:
from unittest import skipIf
except ImportError:
# python<2.7
from django.utils.unittest import skipIf
from django.db.models.query import QuerySet from django.db.models.query import QuerySet
from django.test import TestCase from django.test import TestCase
from django.db.models import Q, Count from django.db.models import Q, Count
if django.VERSION >= (1, 8):
from django.db.models import Case, When
from django.db import models from django.db import models
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.utils import six from django.utils import six
@ -26,6 +19,16 @@ from polymorphic.models import PolymorphicModel
from polymorphic.managers import PolymorphicManager from polymorphic.managers import PolymorphicManager
from polymorphic.query import PolymorphicQuerySet from polymorphic.query import PolymorphicQuerySet
from polymorphic.showfields import ShowFieldContent, ShowFieldType, ShowFieldTypeAndContent from polymorphic.showfields import ShowFieldContent, ShowFieldType, ShowFieldTypeAndContent
try:
from unittest import skipIf
except ImportError:
# python<2.7
from django.utils.unittest import skipIf
if django.VERSION >= (1, 8):
from django.db.models import Case, When
try: try:
from django.db.models import UUIDField from django.db.models import UUIDField
except ImportError: except ImportError: