Skip to content

Commit 1ba62c9

Browse files
authored
Update Python builtin keywords, functions, and exceptions to Python version 3 (#2109)
* refactor: drop duplicate entry Signed-off-by: Joris Clement <7713214+joclement@users.noreply.github.com> * feat!: update builtin keyword, function, and exception to Python version 3 See: - https://docs.python.org/3/reference/lexical_analysis.html#keywords - https://docs.python.org/3/library/functions.html - https://docs.python.org/3/library/exceptions.html#exception-hierarchy Signed-off-by: Joris Clement <7713214+joclement@users.noreply.github.com> * feat!: no longer detect Python2 Signed-off-by: Joris Clement <7713214+joclement@users.noreply.github.com> * fix: continue supporting Python2 See #2109 (comment). Revert "feat!: no longer detect Python2" This reverts commit 3666812. * fix: keep Python2 keywords See #2109 (comment). * style: avoid too long lines --------- Signed-off-by: Joris Clement <7713214+joclement@users.noreply.github.com>
1 parent f522e6c commit 1ba62c9

File tree

1 file changed

+32
-29
lines changed

1 file changed

+32
-29
lines changed

lib/rouge/lexers/python.rb

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,24 @@ def self.keywords
2020
@keywords ||= %w(
2121
assert break continue del elif else except exec
2222
finally for global if lambda pass print raise
23-
return try while yield as with from import yield
23+
return try while yield as with from import
2424
async await nonlocal
2525
)
2626
end
2727

2828
def self.builtins
2929
@builtins ||= %w(
30-
__import__ abs all any apply ascii basestring bin bool buffer
31-
bytearray bytes callable chr classmethod cmp coerce compile
32-
complex delattr dict dir divmod enumerate eval execfile exit
33-
file filter float format frozenset getattr globals hasattr hash hex id
34-
input int intern isinstance issubclass iter len list locals
35-
long map max memoryview min next object oct open ord pow property range
36-
raw_input reduce reload repr reversed round set setattr slice
37-
sorted staticmethod str sum super tuple type unichr unicode
38-
vars xrange zip
30+
__import__ abs aiter all anext any apply ascii
31+
basestring bin bool buffer breakpoint bytearray bytes
32+
callable chr classmethod cmp coerce compile complex
33+
delattr dict dir divmod enumerate eval exec execfile exit
34+
file filter float format frozenset getattr globals
35+
hasattr hash help hex
36+
id input int intern isinstance issubclass iter len list locals long
37+
map max memoryview min next object oct open ord pow print property
38+
range raw_input reduce reload repr reversed round set setattr slice
39+
sorted staticmethod str sum super tuple type unichr unicode vars
40+
xrange zip
3941
)
4042
end
4143

@@ -45,25 +47,26 @@ def self.builtins_pseudo
4547

4648
def self.exceptions
4749
@exceptions ||= %w(
48-
ArithmeticError AssertionError AttributeError
49-
BaseException BlockingIOError BrokenPipeError BufferError
50-
BytesWarning ChildProcessError ConnectionAbortedError
51-
ConnectionError ConnectionRefusedError ConnectionResetError
52-
DeprecationWarning EOFError EnvironmentError
53-
Exception FileExistsError FileNotFoundError
54-
FloatingPointError FutureWarning GeneratorExit IOError
55-
ImportError ImportWarning IndentationError IndexError
56-
InterruptedError IsADirectoryError KeyError KeyboardInterrupt
57-
LookupError MemoryError ModuleNotFoundError NameError
58-
NotADirectoryError NotImplemented NotImplementedError OSError
59-
OverflowError OverflowWarning PendingDeprecationWarning
60-
ProcessLookupError RecursionError ReferenceError ResourceWarning
61-
RuntimeError RuntimeWarning StandardError StopAsyncIteration
62-
StopIteration SyntaxError SyntaxWarning SystemError SystemExit
63-
TabError TimeoutError TypeError UnboundLocalError UnicodeDecodeError
64-
UnicodeEncodeError UnicodeError UnicodeTranslateError
65-
UnicodeWarning UserWarning ValueError VMSError Warning
66-
WindowsError ZeroDivisionError
50+
ArithmeticError AssertionError AttributeError BaseException
51+
BaseExceptionGroup BlockingIOError BrokenPipeError BufferError
52+
BytesWarning ChildProcessError ConnectionAbortedError ConnectionError
53+
ConnectionRefusedError ConnectionResetError DeprecationWarning
54+
EOFError EnvironmentError EncodingWarning Exception ExceptionGroup
55+
FileExistsError FileNotFoundError FloatingPointError FutureWarning
56+
GeneratorExit IOError ImportError ImportWarning IndentationError
57+
IndexError InterruptedError IsADirectoryError
58+
KeyError KeyboardInterrupt LookupError
59+
MemoryError ModuleNotFoundError
60+
NameError NotADirectoryError NotImplemented NotImplementedError
61+
OSError OverflowError OverflowWarning PendingDeprecationWarning
62+
PermissionError ProcessLookupError PythonFinalizationError
63+
RecursionError ReferenceError ResourceWarning RuntimeError RuntimeWarning
64+
StandardError StopAsyncIteration StopIteration SyntaxError SyntaxWarning
65+
SystemError SystemExit TabError TimeoutError TypeError
66+
UnboundLocalError UnicodeDecodeError UnicodeEncodeError UnicodeError
67+
UnicodeTranslateError UnicodeWarning UserWarning ValueError VMSError
68+
Warning WindowsError
69+
ZeroDivisionError
6770
)
6871
end
6972

0 commit comments

Comments
 (0)