Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/libcst/_parser/parso/python/py_token.py: 96%
23 statements
« prev ^ index » next coverage.py v7.3.1, created at 2023-09-25 06:43 +0000
« prev ^ index » next coverage.py v7.3.1, created at 2023-09-25 06:43 +0000
1# Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
2# Licensed to PSF under a Contributor Agreement.
3#
4# Modifications:
5# Copyright David Halter and Contributors
6# Modifications are dual-licensed: MIT and PSF.
7# 99% of the code is different from pgen2, now.
8#
9# A fork of `parso.python.token`.
10# https://github.com/davidhalter/parso/blob/master/parso/python/token.py
11#
12# The following changes were made:
13# - Explicit TokenType references instead of dynamic creation.
14# - Use dataclasses instead of raw classes.
15# pyre-unsafe
17from dataclasses import dataclass
20@dataclass(frozen=True)
21class TokenType:
22 name: str
23 contains_syntax: bool = False
25 def __repr__(self) -> str:
26 return "%s(%s)" % (self.__class__.__name__, self.name)
29class PythonTokenTypes:
30 """
31 Basically an enum, but Python 2 doesn't have enums in the standard library.
32 """
34 STRING: TokenType = TokenType("STRING")
35 NUMBER: TokenType = TokenType("NUMBER")
36 NAME: TokenType = TokenType("NAME", contains_syntax=True)
37 ERRORTOKEN: TokenType = TokenType("ERRORTOKEN")
38 NEWLINE: TokenType = TokenType("NEWLINE")
39 INDENT: TokenType = TokenType("INDENT")
40 DEDENT: TokenType = TokenType("DEDENT")
41 ERROR_DEDENT: TokenType = TokenType("ERROR_DEDENT")
42 ASYNC: TokenType = TokenType("ASYNC")
43 AWAIT: TokenType = TokenType("AWAIT")
44 FSTRING_STRING: TokenType = TokenType("FSTRING_STRING")
45 FSTRING_START: TokenType = TokenType("FSTRING_START")
46 FSTRING_END: TokenType = TokenType("FSTRING_END")
47 OP: TokenType = TokenType("OP", contains_syntax=True)
48 ENDMARKER: TokenType = TokenType("ENDMARKER")