Replies: 1 comment
-
| You could temporarily comment out the  | 
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.
-
Is there any typing trick that can protect against the following coding mistake:
I'm working with a huge codebase where we are doing a big refactor where [0][0] is being changed to [0] due to an API change, but since str[0] is still a string, everything type checks, even if we forget to remove the double subscription.
We almost never want to actually get a single character from a string, and already had two major production bugs due to forgotten double subscripts.
If there's something that mypy can catch - amazing, but a runtime error would be also be valuable, it's better than the code continuing to execute with the incorrect string.
I was thinking in the direction of creating a subclass of
strand casting/typing fruits tolist[MyStr]and overriding thegetitemfunction to return an error, but was wondering if there's something better.Beta Was this translation helpful? Give feedback.
All reactions