Usage¶
Command Line¶
Check modules can be imported.
Modules can be given as the MODULE argument or in the configuration file.
importcheck [OPTIONS] [MODULE]...
Options
-
--version
¶
Show the version and exit.
-
-v
,
--verbose
¶
Show verbose output.
-
-C
,
--count
,
--no-count
¶
Whether to show a count of the passed and failed imports at the end.
-
-s
,
--show
,
--no-show
¶
Whether to show stdout and stderr generated from imports.
-
--colour
,
--no-colour
¶
Whether to use coloured output.
-
-c
,
--config-file
<config_file>
¶ The path to the TOML configuration file to use.
- Default
pyproject.toml
Arguments
-
MODULE
¶
Optional argument(s). Default
None
Changed in version 0.2.0: The list of modules to check can also be read from stdin if -
is given as the first argument.
Example:
find importcheck/*.py | python3 -m importcheck - -s
importcheck version 0.0.0
Checking 'importcheck.__init__'....Passed
Checking 'importcheck.__main__'....Passed
Configuration¶
importcheck
is configured in a TOML file.
By default this is pyproject.toml,
but any other TOML
file can be used by setting the -c
option.
In pyproject.toml
, the configuration is placed in the tool.importcheck
table.
In other TOML
files the configuration may also be placed in the top-level importcheck
table.
The structure of the configuration is as follows:
always: An array of strings giving modules which
importcheck
should always try to import.only_if: A table mapping PEP 508 markers to arrays of strings giving modules which
importcheck
should try to import only if the markers evaluate toTrue
. Each key may contain multiple markers.config: A mapping of internal configuration for
importcheck
. The currently supported values are:show
(boolean) – Sets a default value for-s / --show
.count
(boolean) – Sets a default value for-C / --count
.
These can be overridden on the command line.
Example configuration:
[tool.importcheck]
always = [ "mypackage", "mypackage.submodule",]
[tool.importcheck.only_if]
"sys_platform == 'linux'" = [ "mypackage._linux_helpers",]
[tool.importcheck.config]
show = true
count = true