Ignore some `__init__.py` files with `--recursive` flag
I use mkinit with --recursive flag
Can I make to mkinit ignore some __init__.py files?
I don't want these files to be generated automatically, I want to control them manually
In the current implementation no. In static_mkinit.py line 91 the logic for recursive is:
if recursive:
if submodules is not None:
raise AssertionError("cannot specify submodules in recursive mode")
all_init_fpaths = list(
static.package_modpaths(modpath, with_pkg=True, with_mod=False)
)
all_init_fpaths = sorted(all_init_fpaths, key=lambda x: x.count(os.sep))
for fpath in reversed(all_init_fpaths):
autogen_init(
fpath,
submodules=None,
respect_all=respect_all,
options=options,
dry=dry,
diff=diff,
recursive=False,
)
There would need to be some logic that either removed or ignored the init files you want to control from the all_init_fpaths list. Not sure what the best implementation of that feature would be.
Perhaps we could add another user declaration "dunder" flag that tells mkinit to skip that file? Or we could pass in a list of files to skip, that seems unwieldy. I'm open to suggestions / PRs on this topic.
Can to add comments that we add to the __init__.py file so that it is ignored (# pragma: no autogen)
Or can add the --strict parameter, which requires <AUTORUN_INIT>, or ignore it
I think the functionality is useful, not in all `init.py ' we need to import everything