Please check File
| Settings
(Preferences
on macOS) | Editor
| File Types
, ensure that file name or extension is not listed in Text files.
To fix the problem remove it from the Text files and double check that .py
extension is associated with Python files.