Issue with Context annotations
Since the Context class is in the same file as the code that imports the mutmut_config, it cannot be used for the annotations. We are extensively using annotations in our code and want to do the same for mutmut_config.py.
The issue is probably caused by cyclic import error and is shout since the import exceptions are in try-except.
I suggest moving the class into a separate module. In general, I think it's a good idea to separate the code into a few modules.
Can't you handle this already with https://mypy.readthedocs.io/en/stable/common_issues.html#import-cycles ?
Can't you handle this already with https://mypy.readthedocs.io/en/stable/common_issues.html#import-cycles ?
@boxed Technically we can, but since we are using the other (conventional) way of annotating our methods, it would have been nice to have a way to do it, but not use a tweak.
As some say,
Simple is better than complex.
I can make a PR if you'll be able to merge and make a release.
Hm.. well, I don't think moving the class to another module will help much, as you'd still trigger the import in __init__.py to get to a submodule right?
You'd have to make PR that changes the code so that the mutmut_config isn't imported automatically like that. This seems like a good change anyway since this is more of a hack than a good design imo. Maybe something like a function in mutmut/__init__.py called read_config that does looks something like this:
def read_config():
try:
import mutmut_config as mc
global mutmut_config
mutmut_config = mc
except ImportError:
pass
and then make sure that it's called by main().
Hm.. well, I don't think moving the class to another module will help much, as you'd still trigger the import in
__init__.pyto get to a submodule right?You'd have to make PR that changes the code so that the mutmut_config isn't imported automatically like that. This seems like a good change anyway since this is more of a hack than a good design imo. Maybe something like a function in
mutmut/__init__.pycalledread_configthat does looks something like this:def read_config(): try: import mutmut_config as mc global mutmut_config mutmut_config = mc except ImportError: passand then make sure that it's called by
main().
Let me think a bit over this later today, I'll propose smt in a PR