Mypy error when inferring type of Enum column #698
              
                Unanswered
              
          
                  
                    
                      yonaszmerla
                    
                  
                
                  asked this question in
                Questions
              
            Replies: 1 comment
-
| Using  from sqlmodel import col
...
def get_test_enum() -> Optional[TestEnum]:
    return session.exec(
        select(col(MyTest.test_enum))
    ).first() | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
Create MyTest SQLModel class with custom str_enum field
Retrieve this column from the DB using sqlmodel
The type inferred by mypy is str and not enum as it should be
I will get an error from MyPy
On the return value of
def get_test_enum() -> Optional[TestEnum]:Operating System
macOS
Operating System Details
Ventura 13.2.1
SQLModel Version
0.0.11
Python Version
3.9.18
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions