Replies: 1 comment 4 replies
-
In your example above, If you want to use static typing, attributes on a class must be declared. If you're adding dynamic attributes to an object that are not declared, then a static type checker will not know about them and will complain if you attempt to access them. There are many ways to eliminate circular dependencies in your code, most of them involving refactoring. The technique you're using here looks very hacky. I'd need to understand your scenario better to offer more concrete suggestions. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Say we have a file
extensions.py
where:in the
main.py
we:Then, to avoid circular import, in
whatever.py
which is imported bymain.py
:The problem
Pyright does not know that
foo_instance.something
exists and reportsreportOptionalMemberAccess
.Is there a solution? Related to viniciuschiele/flask-apscheduler#249
Beta Was this translation helpful? Give feedback.
All reactions