Skip to content

Issue with python 3.12 and date and datetime fields. #425

Closed
@matejsp

Description

@matejsp

When running pylint on 3.11 everthing works. However under python 3.12 for date and datetime fields we started to get pylint errors:

account/models/bank_transaction.py:42: [E1101(no-member), BankTransaction.to_dict] Instance of 'DateField' has no 'day' member
account/models/bank_transaction.py:42: [E1101(no-member), BankTransaction.to_dict] Instance of 'DateField' has no 'month' member
account/models/bank_transaction.py:42: [E1101(no-member), BankTransaction.to_dict] Instance of 'DateField' has no 'year' member
account/models/user_profile.py:240: [E1101(no-member), UserProfile.get_report] Instance of 'DateTimeField' has no 'month' member
account/models/user_profile.py:240: [E1101(no-member), UserProfile.get_report] Instance of 'DateTimeField' has no 'year' member
class BankTransaction(models.Model):
    book_date = models.DateField('Book date', db_index=True)
    val_date = models.DateField('Val date', db_index=True)

    def to_dict(self):
        return {
            'id': self.id,
            'bookDate': datetime.datetime(year=self.book_date.year, month=self.book_date.month, day=self.book_date.day),
            'valDate': datetime.datetime(year=self.val_date.year, month=self.val_date.month, day=self.val_date.day)
       }

class UserProfile(models.Model):
    user = models.OneToOneField(auth_models.User, on_delete=models.CASCADE)

    def get_volume_report(self) -> typing.List[typing.List]:
        current_month = datetime.datetime(self.user.date_joined.year, self.user.date_joined.month, 1)

We are using:
django==4.2.8
pylint==3.0.3
pylint-django==2.5.5
pylint-plugin-utils==0.8.2
pylint-protobuf==0.22.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions