简体   繁体   中英

PyCharm: python build-in exceptions unresolved

I have a working Django PyCharm 3.4.1 project which i have been working on for month without problems!

But now PyCharm for some reason marks all python build-in exceptions as unresolved . Other Features like code completion and debugging remain to work fine.

How it happend

The issue started as i created a package named "exceptions" and tried to move a few Exception-derived classed via "refactor" into that package - the operation completed without displaying any error but the involved source files were not modified as if the operation did not happen.

After realizing the possible name conflict with the build-in exceptions i deleted the folder - effectively putting the source files back into the initial state.

Additional Description

  • At that point exceptions like IOError, Exception, KeyError where not resolved correct any more.
  • As a quickfix the IDE suggests to create the respective class, rename the reference or ignore the problem.
  • the editor shows unresolved reference but in the project explorer the concerned files are not underlined red.

Attempts to fix the issue

Unfortunate the issue remained even after i:

  • closed and reopened the project
  • invalidated all Caches and restarted the IDE multiple times
  • switched the python interpreter

Do you have ideas or suggestions on how to make PyCharm get these names right again and to resolve the issue?

I found a way to resolve the issue:

  1. exported "File types" IDE-settings
  2. exchanged the filetypes.xml which looked like this

     <?xml version="1.0" encoding="UTF-8"?> <application> <component name="FileTypeManager" version="11"> <ignoreFiles list="CVS;SCCS;RCS;rcs;.DS_Store;.svn;.pyc;.pyo;*.pyc;*.pyo;.git;*.hprof;_svn;.hg;*.lib;*~;__pycache__;.bundle;*.rbc;*$py.class;" /> <extensionMap> <mapping pattern="exceptions.py" type="PLAIN_TEXT" /> <mapping ext="spec" type="PLAIN_TEXT" /> </extensionMap> </component> </application> 

with

    <?xml version="1.0" encoding="UTF-8"?>
    <application>
      <component name="FileTypeManager" version="11">
        <ignoreFiles list="CVS;SCCS;RCS;rcs;.DS_Store;.svn;.pyc;.pyo;*.pyc;*.pyo;.git;*.hprof;_svn;.hg;*.lib;*~;__pycache__;.bundle;*.rbc;*$py.class;" />
        <extensionMap>
          <mapping ext="spec" type="PLAIN_TEXT" />
        </extensionMap>
      </component>
    </application>
  1. imported the modified settings.jar back into the IDE.

After searching for about 7 hours for what causes the bug by exporting settings, resetting all IDE settings and importing settings back module my module i found this solution.

After identifying the filetypes module of the IDE as the problem i tried to modify the problematic module via the settings dialog but could not find a way.

I wander what caused the IDE to create the

    <mapping pattern="exceptions.py" type="PLAIN_TEXT" />

entry - when trying to reproduce the issue it would no longer occur - even my refactoring operation succeed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM