Skip to main content

A Python module checker

Project description

mck is a Python module checker that verifies if one or more modules can be imported individually.

Some existing Python projects have many modules. In some cases, if you run pydoc, try to generate a reference with Sphinx or want to create unit tests, many of the modules will fail to import.

In these cases, mck can quickly check every module, helping to identify the cause of each error and if there are similar errors, in order to fix them. The output of mck shows all the errors in one place and the progress in fixing them.

The following is a very simple project, it has a package with only two modules:

package/module1.py

import package.module2

def f():
    pass

package/module2.py

from package.module1 import f

def g():
    f()

Will each module import? Instead of manually trying import package.module1 and import package.module2, we run mck and supply the path to the folder of the package:

py -m mck path/package
1 package.module1
Traceback (most recent call last):
  File "~/Documents/mck/example/fails/package/module1.py", line 1, in <module>
    import package.module2
  File "~/Documents/mck/example/fails/package/module2.py", line 1, in <module>
    from package.module1 import f
ImportError: cannot import name 'f' from partially initialized module 'package.module1' (most likely due to a circular import) (~/Documents/mck/example/fails/package/module1.py) package.module2

1 module(s) failed out of 2

The output shows that module1 fails and module2 passes. The first module fails due to ImportError: cannot import name 'f' from partially initialized module. We can fix this error by changing the import and the reference to function f in module2 to this:

package/module2.py

import package.module1

def g():
    package.module1.f()

The output of mck now shows that the error has been fixed and all modules pass :

py -m mck path/package
✓ package.module1
✓ package.module2

0 module(s) failed out of 2

mck is available here in the Python Package Index (PyPI) for installation using pip, and this is the source code repository in Gitlab.

The name mck is based on the name of other checker programs like fsck, pvck, vgck, pwck.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mck-0.2.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mck-0.2-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file mck-0.2.tar.gz.

File metadata

  • Download URL: mck-0.2.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for mck-0.2.tar.gz
Algorithm Hash digest
SHA256 c6fae57efe25b4aabf67351fd2967508877f228eb4d8e2723cbf1cad7fed8cee
MD5 fd42d05546e648c30e7039e6ffed329a
BLAKE2b-256 586622c85e57a0fd5b7a14e1bad70d1540fef8d81314ce3dae4e4aec5b0ceb7d

See more details on using hashes here.

File details

Details for the file mck-0.2-py3-none-any.whl.

File metadata

  • Download URL: mck-0.2-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for mck-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2914c2042972188c9380206a95694ff48e5f279cbf6d587e6384f17d96915f09
MD5 0d89d56c0633398c1ba43e42faecb726
BLAKE2b-256 c006bce0c48afa3f32ef0b662640f5f04f3b50676aa5c647795b15e573097142

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page