I want add a method to a class, without extending another class (for the import statements should be unaltered).
Conceptually, my current approach is:
add_method.py
def new_method():
pass
MyObject.new_method = new_method
main.py
from package import MyObject
import add_method
ob = MyObject()
ob.new_method()
This does the job, however, PyCharm does not recognize that the import add_method
import statement is acutally used: "Unused import statement". Is there an elegant way to obtain the same effect with PyCharm recognizing the import?