PyCharm gives a type warning when working with a MongoEngine field's value. For example, when working with StringField as with str:
class ExampleDocument(Document):
s = StringField()
doc = ExampleDocument(s='mongoengine-test')
print(doc.s.endswith('test'))
I get a warning Unresolved attribute reference 'endswith' for class StringField unless I use typing.cast (i.e. typing.cast(str, doc.s).endswith('test'). The code executes as intended, but is there any way to get rid of these warnings and also to get the necessary autocompletes for MongoEngine field types?