You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The idea is that the sympy package is a heavy import and I thus just want to import it lazily when necessary. Yet, I want to give proper types, which in principle is possible using strings. Additionally using the TYPE_CHECKING guard, mypy can still check the types.
The problem is that pyupgrade automatically changes the code to
which doesn't run anymore since sympy.Symbol is not available in a normal context (when TYPE_CHECKING is False).
Is there a work-around with which I can prevent this problem?
The text was updated successfully, but these errors were encountered:
Yeah, the issue was that my IDE is not smart enough about this and marked an error. I mistakenly thought that python had a problem with the undefined sympy, but apparently it is smarter than I thought :) All good!
pyupgrade
aggressively replaces types that are given as strings, which breaks my code. Here's minimal code to demonstrate the problem:The idea is that the
sympy
package is a heavy import and I thus just want to import it lazily when necessary. Yet, I want to give proper types, which in principle is possible using strings. Additionally using theTYPE_CHECKING
guard,mypy
can still check the types.The problem is that
pyupgrade
automatically changes the code towhich doesn't run anymore since
sympy.Symbol
is not available in a normal context (whenTYPE_CHECKING
isFalse
).Is there a work-around with which I can prevent this problem?
The text was updated successfully, but these errors were encountered: