diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-05-20 07:58:40 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-05-20 08:05:00 +0300 |
commit | bcd5bcc390793791d293d386b2ebefbe683fb4e1 (patch) | |
tree | c93e3b8c847237e7e7626f4a07f1b657bb34f04d /contrib/python/Pygments/py3/pygments/lexers/python.py | |
parent | 1a9f1508fe9c8c5927ffebf33197a6108e70501d (diff) | |
download | ydb-bcd5bcc390793791d293d386b2ebefbe683fb4e1.tar.gz |
Intermediate changes
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/lexers/python.py')
-rw-r--r-- | contrib/python/Pygments/py3/pygments/lexers/python.py | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/contrib/python/Pygments/py3/pygments/lexers/python.py b/contrib/python/Pygments/py3/pygments/lexers/python.py index cdb88ab43a..287305c75c 100644 --- a/contrib/python/Pygments/py3/pygments/lexers/python.py +++ b/contrib/python/Pygments/py3/pygments/lexers/python.py @@ -4,15 +4,14 @@ Lexers for Python and related languages. - :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS. + :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ -import re import keyword -from pygments.lexer import DelegatingLexer, Lexer, RegexLexer, include, \ - bygroups, using, default, words, combined, do_insertions, this, line_re +from pygments.lexer import DelegatingLexer, RegexLexer, include, \ + bygroups, using, default, words, combined, this from pygments.util import get_bool_opt, shebang_matches from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Generic, Other, Error, Whitespace @@ -27,8 +26,6 @@ class PythonLexer(RegexLexer): """ For Python source code (version 3.x). - .. versionadded:: 0.10 - .. versionchanged:: 2.5 This is now the default ``PythonLexer``. It is still available as the alias ``Python3Lexer``. @@ -61,8 +58,9 @@ class PythonLexer(RegexLexer): ] mimetypes = ['text/x-python', 'application/x-python', 'text/x-python3', 'application/x-python3'] + version_added = '0.10' - uni_name = "[%s][%s]*" % (uni.xid_start, uni.xid_continue) + uni_name = f"[{uni.xid_start}][{uni.xid_continue}]*" def innerstring_rules(ttype): return [ @@ -224,7 +222,8 @@ class PythonLexer(RegexLexer): r'(match|case)\b' # a possible keyword r'(?![ \t]*(?:' # not followed by... r'[:,;=^&|@~)\]}]|(?:' + # characters and keywords that mean this isn't - r'|'.join(keyword.kwlist) + r')\b))', # pattern matching + # pattern matching (but None/True/False is ok) + r'|'.join(k for k in keyword.kwlist if k[0].islower()) + r')\b))', bygroups(Text, Keyword), 'soft-keywords-inner'), ], 'soft-keywords-inner': [ @@ -429,6 +428,7 @@ class Python2Lexer(RegexLexer): aliases = ['python2', 'py2'] filenames = [] # now taken over by PythonLexer (3.x) mimetypes = ['text/x-python2', 'application/x-python2'] + version_added = '' def innerstring_rules(ttype): return [ @@ -637,7 +637,7 @@ class Python2Lexer(RegexLexer): class _PythonConsoleLexerBase(RegexLexer): name = 'Python console session' - aliases = ['pycon'] + aliases = ['pycon', 'python-console'] mimetypes = ['text/x-python-doctest'] """Auxiliary lexer for `PythonConsoleLexer`. @@ -696,8 +696,10 @@ class PythonConsoleLexer(DelegatingLexer): """ name = 'Python console session' - aliases = ['pycon'] + aliases = ['pycon', 'python-console'] mimetypes = ['text/x-python-doctest'] + url = 'https://python.org' + version_added = '' def __init__(self, **options): python3 = get_bool_opt(options, 'python3', True) @@ -721,8 +723,6 @@ class PythonTracebackLexer(RegexLexer): """ For Python 3.x tracebacks, with support for chained exceptions. - .. versionadded:: 1.0 - .. versionchanged:: 2.5 This is now the default ``PythonTracebackLexer``. It is still available as the alias ``Python3TracebackLexer``. @@ -732,6 +732,8 @@ class PythonTracebackLexer(RegexLexer): aliases = ['pytb', 'py3tb'] filenames = ['*.pytb', '*.py3tb'] mimetypes = ['text/x-python-traceback', 'text/x-python3-traceback'] + url = 'https://python.org' + version_added = '1.0' tokens = { 'root': [ @@ -778,8 +780,6 @@ class Python2TracebackLexer(RegexLexer): """ For Python tracebacks. - .. versionadded:: 0.7 - .. versionchanged:: 2.5 This class has been renamed from ``PythonTracebackLexer``. ``PythonTracebackLexer`` now refers to the Python 3 variant. @@ -789,6 +789,8 @@ class Python2TracebackLexer(RegexLexer): aliases = ['py2tb'] filenames = ['*.py2tb'] mimetypes = ['text/x-python2-traceback'] + url = 'https://python.org' + version_added = '0.7' tokens = { 'root': [ @@ -825,8 +827,6 @@ class Python2TracebackLexer(RegexLexer): class CythonLexer(RegexLexer): """ For Pyrex and Cython source code. - - .. versionadded:: 1.1 """ name = 'Cython' @@ -834,6 +834,7 @@ class CythonLexer(RegexLexer): aliases = ['cython', 'pyx', 'pyrex'] filenames = ['*.pyx', '*.pxd', '*.pxi'] mimetypes = ['text/x-cython', 'application/x-cython'] + version_added = '1.1' tokens = { 'root': [ @@ -1007,13 +1008,13 @@ class DgLexer(RegexLexer): Lexer for dg, a functional and object-oriented programming language running on the CPython 3 VM. - - .. versionadded:: 1.6 """ name = 'dg' aliases = ['dg'] filenames = ['*.dg'] mimetypes = ['text/x-dg'] + url = 'http://pyos.github.io/dg' + version_added = '1.6' tokens = { 'root': [ @@ -1104,13 +1105,12 @@ class DgLexer(RegexLexer): class NumPyLexer(PythonLexer): """ A Python lexer recognizing Numerical Python builtins. - - .. versionadded:: 0.10 """ name = 'NumPy' url = 'https://numpy.org/' aliases = ['numpy'] + version_added = '0.10' # override the mimetypes to not inherit them from python mimetypes = [] |