Skip to content

GH-134872: add ModuleNotFoundError suggestions#142512

Merged
FFY00 merged 2 commits intopython:mainfrom
FFY00:ModuleNotFoundError-suggestions
Feb 19, 2026
Merged

GH-134872: add ModuleNotFoundError suggestions#142512
FFY00 merged 2 commits intopython:mainfrom
FFY00:ModuleNotFoundError-suggestions

Conversation

@FFY00
Copy link
Member

@FFY00 FFY00 commented Dec 10, 2025

@FFY00
Copy link
Member Author

FFY00 commented Dec 10, 2025

@Locked-chess-official, this draft PR includes the changes from GH-139900, introducing the .discover() method, and my initial proposed traceback implementation.

I think it should address the concerns you raised in GH-139899, could you give it a look?

@FFY00
Copy link
Member Author

FFY00 commented Dec 10, 2025

Right now it doesn't special-case relative imports, but the message is still helpful.

Python 3.15.0a2+ free-threading build (heads/gh-139899:6816705de0c, Dec 10 2025, 12:54:51) [GCC 15.2.1 20251112] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import aa
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    import aa
  File "/home/anubis/git/cpython/test-cases/aa/__init__.py", line 1, in <module>
    from .bb import *
ModuleNotFoundError: No module named 'aa.bb'. Did you mean: 'aa.bbb'?

I think it should be alright for an initial implementation, and then we can improve — just trying to make the scope smaller to hopefully guarantee this proposal doesn't lose momentum and ends up stalled.

@FFY00 FFY00 force-pushed the ModuleNotFoundError-suggestions branch from 3ef83d6 to 889c7ce Compare December 10, 2025 13:13
@FFY00 FFY00 force-pushed the ModuleNotFoundError-suggestions branch from 889c7ce to c98677f Compare February 19, 2026 15:27
@FFY00 FFY00 marked this pull request as ready for review February 19, 2026 15:33
Signed-off-by: Filipe Laíns <lains@riseup.net>
@FFY00 FFY00 force-pushed the ModuleNotFoundError-suggestions branch from c98677f to c739aa6 Compare February 19, 2026 15:40
Signed-off-by: Filipe Laíns <lains@riseup.net>
@FFY00 FFY00 enabled auto-merge (squash) February 19, 2026 15:42
@FFY00 FFY00 merged commit f282f7a into python:main Feb 19, 2026
47 checks passed
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

Successfully merging this pull request may close these issues.

1 participant

Comments