Skip to main content

change the message in ModuleNotFoundError

Project description

friendly_module_not_found_error

This is a Python package that provides a custom exception class for handling module not found errors in a friendly way.

Installation

To install the package, run the following command:

pip install friendly_module_not_found_error

Usage

Don't need to import the packages. The pth file is already in the site-packages folder. Any using for the module in your programs are undocumental behavior(UB).

You can use the code to test the effects of the package:

import ant

The message raised will change to : "No module named 'ant'. Did you mean 'ast'?"

import multiprocessing.dumy

The message raised will change to : "module 'multiprocessing' has no child module 'dumy'. Did you mean 'dummy'?"

You can also run "test/test.py" to test the effects of the python.

require

python3.7+

In friendly_module_not_found_error verison 0.4.2, it supports python3.7+.

License

This package is licensed under the MIT License. See the LICENSE file for more information.

issues

If you have any questions or suggestions, please open an issue on GitHub.

Contributing

Contributions are welcome! Please submit a pull request with your changes.

Note

If a module that is not a package contains submodules, and those submodules also contain their own submodules, this nested module structure is not supported. When this situation occurs, you should reorganize the code using proper package structure. This approach violates Python's packaging best practices and should be avoided.

To make your custom import hook be supported, you need to define a magic method __find__ to return the list of all modules. For example:

class MyImportHook:
    def __find__(self, name: str=None) -> list[str]:
        """
        Return a list of all modules that are available to the import hook without import them.
        If the "name" is provided, the method should return a list of all submodules that under the module named "name".
        parameter name: The name of the module to find submodules for. If None, return all top modules.
        """
        return []

The __find__ method should return a list of all modules that are available to the import hook without import them. If the "name" is provided, the method should return a list of all submodules that under the module named "name". Or it needs to return all top modules if the "name" is None.

Credits

This package was created by [Locked-chess-official] and is maintained by [Locked-chess-official].

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

friendly_module_not_found_error-0.4.2.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

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

friendly_module_not_found_error-0.4.2-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file friendly_module_not_found_error-0.4.2.tar.gz.

File metadata

File hashes

Hashes for friendly_module_not_found_error-0.4.2.tar.gz
Algorithm Hash digest
SHA256 d27c45f3399b2fb588e654c94fe22c5adde6a59ce4de69fb28273a9b2c4d347f
MD5 ce6c101fc6706504b8d0d83e2a096a4c
BLAKE2b-256 99f6cb1d0bbe3331b9306a52b6379a82bd490460bea8412a067861e8e6d2ef22

See more details on using hashes here.

File details

Details for the file friendly_module_not_found_error-0.4.2-py3-none-any.whl.

File metadata

File hashes

Hashes for friendly_module_not_found_error-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5537b03bb14608325636d64052dc95e3aecf924e8437bd67828c95a5262d719c
MD5 c28ddfa60d78d6a7d256c845595572e6
BLAKE2b-256 9bac46a8f4c6515f84e15d27605498f9eabce166eed6b7aa83a9f1090d70d0eb

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