You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's a weird corner case that I've run into in our code base, where if a model instance is created through direct instantiation, subsequent calls to isoformat with a timespec are flagged, even though this works fine when instantiating through ModelClass.objects.create(). Here's an example (settings.py is an empty file):
$ cat datetimefield.py
# pylint: disable=C
from django.db import models
class A(models.Model):
field = models.DateTimeField(auto_now=True)
x = A()
x.save()
x.field.isoformat(timespec='seconds')
y = A.objects.create()
y.field.isoformat(timespec='seconds')
$ pylint --load-plugins=pylint_django --django-settings-module=settings datetimefield.py
************* Module datetimefield
datetimefield.py:11:0: E1123: Unexpected keyword argument 'timespec' in method call (unexpected-keyword-arg)
-----------------------------------
Your code has been rated at 3.75/10
Here's the environment (I simply installed prospector and django):
I have encountered the same issue. Some more observations:
from django.db import models
from datetime import UTC
class A(models.Model):
field = models.DateTimeField(auto_now=True)
def b(self):
self.field.replace(year=2001) # ok
self.field.replace(month=1) # ok
self.field.replace(day=1) # ok
self.field.replace(hour=1) # unexpected-keyword-arg
self.field.replace(second=1) # unexpected-keyword-arg
self.field.replace(microsecond=1) # unexpected-keyword-arg
self.field.replace(tzinfo=UTC) # unexpected-keyword-arg
self.field.replace(fold=0) # unexpected-keyword-arg
self.field.today() # ok
Here's a weird corner case that I've run into in our code base, where if a model instance is created through direct instantiation, subsequent calls to
isoformat
with atimespec
are flagged, even though this works fine when instantiating throughModelClass.objects.create()
. Here's an example (settings.py is an empty file):Here's the environment (I simply installed prospector and django):
The text was updated successfully, but these errors were encountered: