eric6/QScintilla/Lexers/LexerPython.py

changeset 8243
cc717c2ae956
parent 7923
91e843545d9a
child 8255
2fc483702cd6
diff -r aa713ac50c0d -r cc717c2ae956 eric6/QScintilla/Lexers/LexerPython.py
--- a/eric6/QScintilla/Lexers/LexerPython.py	Thu Apr 15 16:52:05 2021 +0200
+++ b/eric6/QScintilla/Lexers/LexerPython.py	Thu Apr 15 18:11:24 2021 +0200
@@ -8,6 +8,7 @@
 """
 
 import re
+import contextlib
 
 from PyQt5.Qsci import QsciLexerPython, QsciScintilla
 
@@ -130,26 +131,20 @@
         self.setFoldQuotes(Preferences.getEditor("PythonFoldString"))
         if not Preferences.getEditor("PythonAutoIndent"):
             self.setAutoIndentStyle(QsciScintilla.AiMaintain)
-        try:
+        with contextlib.suppress(AttributeError):
             self.setV2UnicodeAllowed(
                 Preferences.getEditor("PythonAllowV2Unicode"))
             self.setV3BinaryOctalAllowed(
                 Preferences.getEditor("PythonAllowV3Binary"))
             self.setV3BytesAllowed(Preferences.getEditor("PythonAllowV3Bytes"))
-        except AttributeError:
-            pass
-        try:
+        with contextlib.suppress(AttributeError):
             self.setFoldQuotes(Preferences.getEditor("PythonFoldQuotes"))
             self.setStringsOverNewlineAllowed(
                 Preferences.getEditor("PythonStringsOverNewLineAllowed"))
-        except AttributeError:
-            pass
-        try:
+        with contextlib.suppress(AttributeError):
             self.setHighlightSubidentifiers(
                 Preferences.getEditor("PythonHighlightSubidentifier"))
-        except AttributeError:
-            pass
-        
+    
     def getIndentationDifference(self, line, editor):
         """
         Public method to determine the difference for the new indentation.

eric ide

mercurial