Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imp module is deprecated and will be removed in Python 3.12 #683

Closed
hugovk opened this issue Apr 24, 2023 · 1 comment
Closed

imp module is deprecated and will be removed in Python 3.12 #683

hugovk opened this issue Apr 24, 2023 · 1 comment
Assignees

Comments

@hugovk
Copy link
Contributor

hugovk commented Apr 24, 2023

This project uses the imp module in two examples:

  • test/example_with_reduce.py
  • test/inspect_example.py

For example:

Python Code

def getmoduleinfo(path):
    """Get the module name, suffix, mode, and module type for a given file."""
    warnings.warn('inspect.getmoduleinfo() is deprecated', DeprecationWarning,
                  2)
    with warnings.catch_warnings():
        warnings.simplefilter('ignore', PendingDeprecationWarning)
        import imp
    filename = os.path.basename(path)
    suffixes = [(-len(suffix), suffix, mode, mtype)
                    for suffix, mode, mtype in imp.get_suffixes()]
    suffixes.sort() # try longest suffixes first, in case they overlap
    for neglen, suffix, mode, mtype in suffixes:
        if filename[neglen:] == suffix:
            return ModuleInfo(filename[:neglen], suffix, mode, mtype)

The imp module is deprecated and set for removal in Python 3.12, due for release in October:

Please update the tests so they will continue working with 3.12.

@hhatto
Copy link
Owner

hhatto commented Mar 17, 2024

This issue has been resolved in autopep8 version 2.1.0.

@hhatto hhatto closed this as completed Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants