question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proper annotations

See original GitHub issue

Right now mypy, pyright and other static type analyzers are screaming from annotations like this: id: Integer(primary_key=True)

mypy error:

lmat/db/models.py:33: error: Invalid type comment or annotation  [valid-type]
lmat/db/models.py:33: note: Suggestion: use Integer[...] instead of Integer(...)

pyright error:

Expected class type but received "Integer" Pyright (reportGeneralTypeIssues)

Why id = Integer(primary_key=True) syntax is not used (like in orm)? I guess it is because of the way you extract annotations, do you consider changing the approach? I would like to use this library in one project, but it is unusable in this state (I cannot just put # type: ignore[valid-type] on every line in models)

Can help with this when I have some spare time, unfortunately I am forced to go back to orm.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

8reactions
zdytchcommented, Jun 25, 2021

Suffering from this right now. In VSCode I have Pylance type checking on. It is based on Pyright and Mypy.

So when I don’t use annotation, like this: size = ormar.Integer(minimum=0, default=0) no screaming

But, when I add annotation: size: int = ormar.Integer(minimum=0, default=0) i get the error:

Expression of type "BaseField" cannot be assigned to declared type "int"
  "BaseField" is incompatible with "int" 

Adding # type: ignore to the file top of the file or to separate line hides the error

3reactions
collerekcommented, Sep 25, 2021

Sorry for late answer, will try to tackle this one in the nearest future. Any help welcomed! 😊

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Annotate | English Composition I
First, determine how you will annotate the text you are about to read. ... Write any comments or observations you feel appropriate to...
Read more >
Annotating a Text - Hunter College - CUNY
Annotating a text, or marking the pages with notes, is an excellent, if not essential, way to make the most out of the...
Read more >
Annotating a Text - Reading and Study Strategies
Annotating is any action that deliberately interacts with a text to enhance the reader's understanding of, recall of, and reaction to the ...
Read more >
Annotation Tips for Students : Hypothesis
In many cases, this means analyze don't summarize — what your teachers have been telling you in English class since middle school. But...
Read more >
4 ways to Annotate a text:
Annotating a text, or marking the pages with notes, is an excellent, ... Annotations make it easy to find important information quickly when....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found