Pycharm warns of unexpected type in SqlAlchemy model

In the SqlAlchemy model, I get a warning from pycharm that the column is of unexpected type.

The simplified warning code is as follows:

from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String

Base = declarative_base()

class Peptide(Base):
    __tablename__ = 'peptides'

    sequence = Column(String, primary_key=True)
    scan = Column(Integer)

    def __init__(self, scan, sequence):
        self.scan = scan
        self.sequence = sequence

    def __repr__(self):
        return '<Peptide "%s" Scan %i>' % (self.sequence, self.scan)

A warning is given for self.scanin method __repr__. If I changed the format string to:

  return '<Peptide "%s" Scan %s>' % (self.sequence, self.scan)

warning disappears. But in fact, self.scan was defined as an integer in the model, not a string. Suddenly, the following line does not generate a warning:

  return '<Scan %i>' % self.scan

Is this an overreaction of the pycharm check or something related to SqlAlchemy types?

+5
source share
1 answer

PyCharm ORM SQLAlchemy, . SQLAlchemy PyCharm, PY-4186 PyCharm.

: PY-4536 2013 . , , Mixins, . PY-12002.

+6

All Articles