Erotemic / mkinit
Showing 3 of 5 files from the diff.

@@ -3,7 +3,7 @@
Loading
3 3
Regenerate Input Command
4 4
mkinit ~/code/mkinit/mkinit
5 5
"""
6 -
__version__ = "0.3.2"
6 +
__version__ = "0.3.3"
7 7
8 8
__submodules__ = [
9 9
    "dynamic_mkinit",

@@ -163,9 +163,11 @@
Loading
163 163
    private = user_decl.get("__private__", [])
164 164
    protected = user_decl.get("__protected__", [])
165 165
    external = user_decl.get("__external__", [])
166 +
    ignore = user_decl.get("__ignore__", [])
166 167
167 168
    modname, imports, from_imports = _static_parse_imports(
168 -
        modpath, submodules=submodules, respect_all=respect_all, external=external
169 +
        modpath, submodules=submodules, respect_all=respect_all,
170 +
        external=external, ignore=ignore
169 171
    )
170 172
171 173
    logger.debug("Found {} imports".format(len(imports)))
@@ -251,6 +253,12 @@
Loading
251 253
            user_decl["__private__"] = static.parse_static_value("__private__", source)
252 254
        except NameError:
253 255
            pass
256 +
257 +
        try:
258 +
            # Ignore these modules and attributes
259 +
            user_decl["__ignore__"] = static.parse_static_value("__ignore__", source)
260 +
        except NameError:
261 +
            pass
254 262
    return user_decl
255 263
256 264
@@ -340,7 +348,7 @@
Loading
340 348
    return valid_attrs
341 349
342 350
343 -
def _static_parse_imports(modpath, submodules=None, external=None, respect_all=True):
351 +
def _static_parse_imports(modpath, submodules=None, external=None, respect_all=True, ignore=None):
344 352
    """
345 353
    Args:
346 354
        modpath (PathLike): base path to a package (with an __init__)
@@ -423,10 +431,16 @@
Loading
423 431
                    "Failed to parse module {!r}, ex = {!r}".format(rel_modname, ex)
424 432
                )
425 433
            else:
434 +
                if ignore:
435 +
                    ignore = set(ignore)
436 +
                    valid_attrs = [v for v in valid_attrs if v not in ignore]
426 437
                from_imports.append(("." + rel_modname, sorted(valid_attrs)))
427 438
        else:
428 439
            valid_attrs = attr_list
429 -
            from_imports.append(("." + rel_modname, attr_list))
440 +
            if ignore:
441 +
                ignore = set(ignore)
442 +
                valid_attrs = [v for v in valid_attrs if v not in ignore]
443 +
            from_imports.append(("." + rel_modname, valid_attrs))
430 444
431 445
    if external:
432 446
        for ext_modname in external:

@@ -382,6 +382,7 @@
Loading
382 382
            r"""
383 383
            def lazy_import(module_name, submodules, submod_attrs):
384 384
                import importlib
385 +
                import os
385 386
                name_to_submod = {
386 387
                    func: mod for mod, funcs in submod_attrs.items()
387 388
                    for func in funcs
@@ -406,6 +407,14 @@
Loading
406 407
                                module_name=module_name, name=name))
407 408
                    globals()[name] = attr
408 409
                    return attr
410 +
411 +
                if os.environ.get('EAGER_IMPORT', ''):
412 +
                    for name in name_to_submod.values():
413 +
                        __getattr__(name)
414 +
415 +
                    for attrs in submod_attrs.values():
416 +
                        for attr in attrs:
417 +
                            __getattr__(attr)
409 418
                return __getattr__
410 419
            """
411 420
        ).rstrip("\n")
Files Coverage
mkinit 84.03%
Project Totals (8 files) 84.03%
1
codecov:
2
  require_ci_to_pass: no
3

4
coverage:
5
  precision: 2
6
  round: down
7
  range: "50...80"
8

9
  status:
10
    project: # settings affecting project coverage
11
      enabled: yes
12
      target: auto # auto % coverage target
13
      threshold: 20%  # allow for 20% reduction of coverage without failing
14

15
    # do not run coverage on patch nor changes
16
    patch:
17
      default:
18
        enabled: false
19
    changes: no
20

21
parsers:
22
  gcov:
23
    branch_detection:
24
      conditional: yes
25
      loop: yes
26
      method: no
27
      macro: no
28

29
comment:
30
  layout: "reach,diff,flags,files,footer"
31
  behavior: default
32
  require_changes: no
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading