Ticket #26176: patch.diff

File patch.diff, 17.7 KB (added by Tim Graham, 5 years ago)
  • django/contrib/admin/checks.py

    diff --git a/django/contrib/admin/checks.py b/django/contrib/admin/checks.py
    index 48539fe..62c3710 100644
    a b def check_dependencies(**kwargs): 
    5858                "'django.contrib.auth.context_processors.auth' must be in "
    5959                "TEMPLATES in order to use the admin application.",
    6060                id="admin.E402"
    61                 )
     61            )
    6262            errors.append(missing_template)
    6363    return errors
    6464
  • django/contrib/flatpages/forms.py

    diff --git a/django/contrib/flatpages/forms.py b/django/contrib/flatpages/forms.py
    index b990fa3..19f3b63 100644
    a b from django.utils.translation import ugettext, ugettext_lazy as _ 
    55
    66
    77class FlatpageForm(forms.ModelForm):
    8     url = forms.RegexField(label=_("URL"), max_length=100, regex=r'^[-\w/\.~]+$',
    9         help_text=_("Example: '/about/contact/'. Make sure to have leading"
    10                     " and trailing slashes."),
     8    url = forms.RegexField(
     9        label=_("URL"),
     10        max_length=100,
     11        regex=r'^[-\w/\.~]+$',
     12        help_text=_("Example: '/about/contact/'. Make sure to have leading and trailing slashes."),
    1113        error_messages={
    12             "invalid": _("This value must contain only letters, numbers,"
    13                          " dots, underscores, dashes, slashes or tildes."),
     14            "invalid": _(
     15                "This value must contain only letters, numbers, dots, "
     16                "underscores, dashes, slashes or tildes."
     17            ),
    1418        },
    1519    )
    1620
  • django/contrib/flatpages/models.py

    diff --git a/django/contrib/flatpages/models.py b/django/contrib/flatpages/models.py
    index 67e1a30..b3cad73 100644
    a b class FlatPage(models.Model): 
    1313    title = models.CharField(_('title'), max_length=200)
    1414    content = models.TextField(_('content'), blank=True)
    1515    enable_comments = models.BooleanField(_('enable comments'), default=False)
    16     template_name = models.CharField(_('template name'), max_length=70, blank=True,
     16    template_name = models.CharField(
     17        _('template name'),
     18        max_length=70,
     19        blank=True,
    1720        help_text=_(
    1821            "Example: 'flatpages/contact_page.html'. If this isn't provided, "
    1922            "the system will use 'flatpages/default.html'."
  • django/contrib/gis/gdal/prototypes/raster.py

    diff --git a/django/contrib/gis/gdal/prototypes/raster.py b/django/contrib/gis/gdal/prototypes/raster.py
    index 4058e19..8b3c350 100644
    a b get_band_ds = voidptr_output(std_call('GDALGetBandDataset'), [c_void_p]) 
    6262get_band_datatype = int_output(std_call('GDALGetRasterDataType'), [c_void_p])
    6363get_band_nodata_value = double_output(std_call('GDALGetRasterNoDataValue'), [c_void_p, POINTER(c_int)])
    6464set_band_nodata_value = void_output(std_call('GDALSetRasterNoDataValue'), [c_void_p, c_double])
    65 get_band_statistics = void_output(std_call('GDALGetRasterStatistics'),
     65get_band_statistics = void_output(
     66    std_call('GDALGetRasterStatistics'),
    6667    [
    6768        c_void_p, c_int, c_int, POINTER(c_double), POINTER(c_double),
    6869        POINTER(c_double), POINTER(c_double), c_void_p, c_void_p,
  • django/views/generic/dates.py

    diff --git a/django/views/generic/dates.py b/django/views/generic/dates.py
    index d403db8..52b3b39 100644
    a b class BaseDateDetailView(YearMixin, MonthMixin, DayMixin, DateMixin, BaseDetailV 
    658658        if not self.get_allow_future() and date > datetime.date.today():
    659659            raise Http404(_(
    660660                "Future %(verbose_name_plural)s not available because "
    661                 "%(class_name)s.allow_future is False.") % {
     661                "%(class_name)s.allow_future is False."
     662            ) % {
    662663                'verbose_name_plural': qs.model._meta.verbose_name_plural,
    663664                'class_name': self.__class__.__name__,
    664                 },
    665             )
     665            })
    666666
    667667        # Filter down a queryset from self.queryset using the date from the
    668668        # URL. This'll get passed as the queryset to DetailView.get_object,
  • setup.cfg

    diff --git a/setup.cfg b/setup.cfg
    index 8579282..f6ab266 100644
    a b install-script = scripts/rpm-install.sh 
    44
    55[flake8]
    66exclude = build,.git,./django/utils/lru_cache.py,./django/utils/six.py,./django/conf/app_template/*,./django/dispatch/weakref_backports.py,./tests/.env,./xmlrunner,tests/view_tests/tests/py3_test_debug.py,tests/template_tests/annotated_tag_function.py
    7 ignore = E123,E128,E402,W503,W601
     7ignore = E128,E402,W503,W601
    88max-line-length = 119
    99
    1010[isort]
  • tests/many_to_one/tests.py

    diff --git a/tests/many_to_one/tests.py b/tests/many_to_one/tests.py
    index b3028e0..52ea5d9 100644
    a b class ManyToOneTests(TestCase): 
    6464
    6565        self.r.article_set.add(new_article2, bulk=False)
    6666        self.assertEqual(new_article2.reporter.id, self.r.id)
    67         self.assertQuerysetEqual(self.r.article_set.all(),
    68             [
    69                 "<Article: John's second story>",
    70                 "<Article: Paul's story>",
    71                 "<Article: This is a test>",
    72             ])
     67        self.assertQuerysetEqual(
     68            self.r.article_set.all(),
     69            ["<Article: John's second story>", "<Article: Paul's story>", "<Article: This is a test>"]
     70        )
    7371
    7472        # Add the same article to a different article set - check that it moves.
    7573        self.r2.article_set.add(new_article2)
    class ManyToOneTests(TestCase): 
    8179            with six.assertRaisesRegex(self, TypeError,
    8280                                       "'Article' instance expected, got <Reporter.*"):
    8381                self.r.article_set.add(self.r2)
    84         self.assertQuerysetEqual(self.r.article_set.all(),
    85             [
    86                 "<Article: John's second story>",
    87                 "<Article: This is a test>",
    88             ])
     82        self.assertQuerysetEqual(
     83            self.r.article_set.all(),
     84            ["<Article: John's second story>", "<Article: This is a test>"]
     85        )
    8986
    9087    def test_set(self):
    91         new_article = self.r.article_set.create(headline="John's second story",
    92                                                 pub_date=datetime.date(2005, 7, 29))
    93         new_article2 = self.r2.article_set.create(headline="Paul's story",
    94                                                   pub_date=datetime.date(2006, 1, 17))
     88        new_article = self.r.article_set.create(headline="John's second story", pub_date=datetime.date(2005, 7, 29))
     89        new_article2 = self.r2.article_set.create(headline="Paul's story", pub_date=datetime.date(2006, 1, 17))
    9590
    9691        # Assign the article to the reporter.
    9792        new_article2.reporter = self.r
    class ManyToOneTests(TestCase): 
    108103        # Set the article back again.
    109104        self.r2.article_set.set([new_article, new_article2])
    110105        self.assertQuerysetEqual(self.r.article_set.all(), ["<Article: This is a test>"])
    111         self.assertQuerysetEqual(self.r2.article_set.all(),
    112             [
    113                 "<Article: John's second story>",
    114                 "<Article: Paul's story>",
    115             ])
     106        self.assertQuerysetEqual(
     107            self.r2.article_set.all(),
     108            ["<Article: John's second story>", "<Article: Paul's story>"]
     109        )
    116110
    117111        # Funny case - because the ForeignKey cannot be null,
    118112        # existing members of the set must remain.
    119113        self.r.article_set.set([new_article])
    120         self.assertQuerysetEqual(self.r.article_set.all(),
    121             [
    122                 "<Article: John's second story>",
    123                 "<Article: This is a test>",
    124             ])
     114        self.assertQuerysetEqual(
     115            self.r.article_set.all(),
     116            ["<Article: John's second story>", "<Article: This is a test>"]
     117        )
    125118        self.assertQuerysetEqual(self.r2.article_set.all(), ["<Article: Paul's story>"])
    126119
    127120    def test_reverse_assignment_deprecation(self):
    class ManyToOneTests(TestCase): 
    134127            self.r2.article_set = []
    135128
    136129    def test_assign(self):
    137         new_article = self.r.article_set.create(headline="John's second story",
    138                                                 pub_date=datetime.date(2005, 7, 29))
    139         new_article2 = self.r2.article_set.create(headline="Paul's story",
    140                                                   pub_date=datetime.date(2006, 1, 17))
     130        new_article = self.r.article_set.create(headline="John's second story", pub_date=datetime.date(2005, 7, 29))
     131        new_article2 = self.r2.article_set.create(headline="Paul's story", pub_date=datetime.date(2006, 1, 17))
    141132
    142133        # Assign the article to the reporter directly using the descriptor.
    143134        new_article2.reporter = self.r
    class ManyToOneTests(TestCase): 
    154145        # Set the article back again using set() method.
    155146        self.r2.article_set.set([new_article, new_article2])
    156147        self.assertQuerysetEqual(self.r.article_set.all(), ["<Article: This is a test>"])
    157         self.assertQuerysetEqual(self.r2.article_set.all(),
    158             [
    159                 "<Article: John's second story>",
    160                 "<Article: Paul's story>",
    161             ])
     148        self.assertQuerysetEqual(
     149            self.r2.article_set.all(),
     150            ["<Article: John's second story>", "<Article: Paul's story>"]
     151        )
    162152
    163153        # Because the ForeignKey cannot be null, existing members of the set
    164154        # must remain.
    165155        self.r.article_set.set([new_article])
    166         self.assertQuerysetEqual(self.r.article_set.all(),
    167             [
    168                 "<Article: John's second story>",
    169                 "<Article: This is a test>",
    170             ])
     156        self.assertQuerysetEqual(
     157            self.r.article_set.all(),
     158            ["<Article: John's second story>", "<Article: This is a test>"]
     159        )
    171160        self.assertQuerysetEqual(self.r2.article_set.all(), ["<Article: Paul's story>"])
    172161        # Reporter cannot be null - there should not be a clear or remove method
    173162        self.assertFalse(hasattr(self.r2.article_set, 'remove'))
    174163        self.assertFalse(hasattr(self.r2.article_set, 'clear'))
    175164
    176165    def test_selects(self):
    177         self.r.article_set.create(headline="John's second story",
    178                                   pub_date=datetime.date(2005, 7, 29))
    179         self.r2.article_set.create(headline="Paul's story",
    180                                    pub_date=datetime.date(2006, 1, 17))
     166        self.r.article_set.create(headline="John's second story", pub_date=datetime.date(2005, 7, 29))
     167        self.r2.article_set.create(headline="Paul's story", pub_date=datetime.date(2006, 1, 17))
    181168        # Reporter objects have access to their related Article objects.
    182169        self.assertQuerysetEqual(self.r.article_set.all(), [
    183170            "<Article: John's second story>",
    class ManyToOneTests(TestCase): 
    199186        # Use double underscores to separate relationships.
    200187        # This works as many levels deep as you want. There's no limit.
    201188        # Find all Articles for any Reporter whose first name is "John".
    202         self.assertQuerysetEqual(Article.objects.filter(reporter__first_name__exact='John'),
    203             [
    204                 "<Article: John's second story>",
    205                 "<Article: This is a test>",
    206             ])
     189        self.assertQuerysetEqual(
     190            Article.objects.filter(reporter__first_name__exact='John'),
     191            ["<Article: John's second story>", "<Article: This is a test>"]
     192        )
    207193        # Check that implied __exact also works
    208         self.assertQuerysetEqual(Article.objects.filter(reporter__first_name='John'),
    209             [
    210                 "<Article: John's second story>",
    211                 "<Article: This is a test>",
    212             ])
     194        self.assertQuerysetEqual(
     195            Article.objects.filter(reporter__first_name='John'),
     196            ["<Article: John's second story>", "<Article: This is a test>"]
     197        )
    213198        # Query twice over the related field.
    214199        self.assertQuerysetEqual(
    215             Article.objects.filter(reporter__first_name__exact='John',
    216                                    reporter__last_name__exact='Smith'),
    217             [
    218                 "<Article: John's second story>",
    219                 "<Article: This is a test>",
    220             ])
     200            Article.objects.filter(reporter__first_name__exact='John', reporter__last_name__exact='Smith'),
     201            ["<Article: John's second story>", "<Article: This is a test>"]
     202        )
    221203        # The underlying query only makes one join when a related table is referenced twice.
    222         queryset = Article.objects.filter(reporter__first_name__exact='John',
    223                                        reporter__last_name__exact='Smith')
     204        queryset = Article.objects.filter(reporter__first_name__exact='John', reporter__last_name__exact='Smith')
    224205        self.assertNumQueries(1, list, queryset)
    225206        self.assertEqual(queryset.query.get_compiler(queryset.db).as_sql()[0].count('INNER JOIN'), 1)
    226207
    class ManyToOneTests(TestCase): 
    228209        self.assertQuerysetEqual(
    229210            Article.objects.filter(reporter__first_name__exact='John').extra(
    230211                where=["many_to_one_reporter.last_name='Smith'"]),
    231             [
    232                 "<Article: John's second story>",
    233                 "<Article: This is a test>",
    234             ])
     212            ["<Article: John's second story>", "<Article: This is a test>"]
     213        )
    235214        # ... and should work fine with the unicode that comes out of forms.Form.cleaned_data
    236215        self.assertQuerysetEqual(
    237216            (Article.objects
    238217                .filter(reporter__first_name__exact='John')
    239218                .extra(where=["many_to_one_reporter.last_name='%s'" % 'Smith'])),
    240             [
    241                 "<Article: John's second story>",
    242                 "<Article: This is a test>",
    243             ])
     219            ["<Article: John's second story>", "<Article: This is a test>"]
     220        )
    244221        # Find all Articles for a Reporter.
    245222        # Use direct ID check, pk check, and object comparison
    246223        self.assertQuerysetEqual(
    class ManyToOneTests(TestCase): 
    376353        r2 = Reporter.objects.create(first_name='John', last_name='Kass', email='jkass@tribune.com')
    377354        Article.objects.create(headline='First', pub_date=datetime.date(1980, 4, 23), reporter=r1)
    378355        Article.objects.create(headline='Second', pub_date=datetime.date(1980, 4, 23), reporter=r2)
    379         self.assertEqual(list(Article.objects.select_related().dates('pub_date', 'day')),
    380             [
    381                 datetime.date(1980, 4, 23),
    382                 datetime.date(2005, 7, 27),
    383             ])
     356        self.assertEqual(
     357            list(Article.objects.select_related().dates('pub_date', 'day')),
     358            [datetime.date(1980, 4, 23), datetime.date(2005, 7, 27)]
     359        )
    384360        self.assertEqual(list(Article.objects.select_related().dates('pub_date', 'month')),
    385             [
    386                 datetime.date(1980, 4, 1),
    387                 datetime.date(2005, 7, 1),
    388             ])
     361            [datetime.date(1980, 4, 1), datetime.date(2005, 7, 1)]
     362        )
    389363        self.assertEqual(list(Article.objects.select_related().dates('pub_date', 'year')),
    390             [
    391                 datetime.date(1980, 1, 1),
    392                 datetime.date(2005, 1, 1),
    393             ])
     364            [datetime.date(1980, 1, 1), datetime.date(2005, 1, 1)]
     365        )
    394366
    395367    def test_delete(self):
    396368        self.r.article_set.create(headline="John's second story",
    class ManyToOneTests(TestCase): 
    402374        Article.objects.create(id=None, headline="Fourth article",
    403375                               pub_date=datetime.date(2005, 7, 27), reporter_id=str(self.r.id))
    404376        # If you delete a reporter, his articles will be deleted.
    405         self.assertQuerysetEqual(Article.objects.all(),
     377        self.assertQuerysetEqual(
     378            Article.objects.all(),
    406379            [
    407380                "<Article: Fourth article>",
    408381                "<Article: John's second story>",
    409382                "<Article: Paul's story>",
    410383                "<Article: Third article>",
    411384                "<Article: This is a test>",
    412             ])
    413         self.assertQuerysetEqual(Reporter.objects.order_by('first_name'),
    414             [
    415                 "<Reporter: John Smith>",
    416                 "<Reporter: Paul Jones>",
    417             ])
     385            ]
     386        )
     387        self.assertQuerysetEqual(
     388            Reporter.objects.order_by('first_name'),
     389            ["<Reporter: John Smith>", "<Reporter: Paul Jones>"]
     390        )
    418391        self.r2.delete()
    419         self.assertQuerysetEqual(Article.objects.all(),
     392        self.assertQuerysetEqual(
     393            Article.objects.all(),
    420394            [
    421395                "<Article: Fourth article>",
    422396                "<Article: John's second story>",
    423397                "<Article: Third article>",
    424398                "<Article: This is a test>",
    425             ])
     399            ]
     400        )
    426401        self.assertQuerysetEqual(Reporter.objects.order_by('first_name'),
    427402                                 ["<Reporter: John Smith>"])
    428403        # You can delete using a JOIN in the query.
    class ManyToOneTests(TestCase): 
    443418        # You can specify filters containing the explicit FK value.
    444419        self.assertQuerysetEqual(
    445420            Article.objects.filter(reporter_id__exact=self.r.id),
    446             [
    447                 "<Article: John's second test>",
    448                 "<Article: This is a test>",
    449             ])
     421            ["<Article: John's second test>", "<Article: This is a test>"]
     422        )
    450423
    451424        # Create an Article by Paul for the same date.
    452425        a3 = Article.objects.create(id=None, headline="Paul's commentary",
Back to Top