Skip to content

Commit 33d3834

Browse files
committed
Fix failing errors
1 parent dd117af commit 33d3834

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Here's a simple example:
3232
.. code-block:: python
3333
3434
# Import the JSONSchemaLexer class from the package
35-
from jsonschema_lexer import JSONSchemaLexer
35+
from jsonschema_lexer.lexer import JSONSchemaLexer
3636
3737
from rich.console import Console
3838
from rich.syntax import Syntax

jsonschema_lexer/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""
2+
Provides the JSONSchema Lexer.
3+
"""

jsonschema_lexer/lexer.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
1+
"""
2+
Contains the main functionality of the JSONSchemaLexer.
3+
"""
4+
5+
from typing import Any, ClassVar
6+
17
from pygments.lexer import RegexLexer, include
28
from pygments.token import Token
39

410

511
def _get_regex_from_options(options: list[str]) -> str:
612
"""
7-
Constructs a regular expression pattern allowing any string from the options list.
13+
Constructs regex allowing any string from the options list.
814
915
Args:
10-
options (list[str]): List of options to be included in the regex pattern.
16+
options (list[str]): List of options to be included
17+
in the regex pattern.
1118
1219
Returns:
1320
str: Regular expression pattern constructed from the options.
1421
1522
"""
1623
options = ['"' + option + '"' for option in options]
17-
regex_str = "(" + "|".join(options) + ")"
18-
return regex_str
24+
return "(" + "|".join(options) + ")"
1925

2026

2127
class JSONSchemaLexer(RegexLexer):
@@ -25,7 +31,7 @@ class JSONSchemaLexer(RegexLexer):
2531

2632
name = "JSON Schema Lexer"
2733

28-
data_types = [
34+
data_types: ClassVar[list[str]] = [
2935
"object",
3036
"integer",
3137
"string",
@@ -34,7 +40,7 @@ class JSONSchemaLexer(RegexLexer):
3440
"boolean",
3541
"null",
3642
]
37-
core_keywords = [
43+
core_keywords: ClassVar[list[str]] = [
3844
r"\$schema",
3945
r"\$id",
4046
r"\$ref",
@@ -45,7 +51,7 @@ class JSONSchemaLexer(RegexLexer):
4551
r"\$anchor",
4652
r"\$vocabulary",
4753
]
48-
applicator_keywords = [
54+
applicator_keywords: ClassVar[list[str]] = [
4955
"oneOf",
5056
"allOf",
5157
"anyOf",
@@ -62,7 +68,7 @@ class JSONSchemaLexer(RegexLexer):
6268
"contains",
6369
"items",
6470
]
65-
meta_data_keywords = [
71+
meta_data_keywords: ClassVar[list[str]] = [
6672
"title",
6773
"description",
6874
"default",
@@ -71,7 +77,7 @@ class JSONSchemaLexer(RegexLexer):
7177
"readOnly",
7278
"writeOnly",
7379
]
74-
validation_keywords = [
80+
validation_keywords: ClassVar[list[str]] = [
7581
"type",
7682
"enum",
7783
"const",
@@ -93,7 +99,7 @@ class JSONSchemaLexer(RegexLexer):
9399
"maxContains",
94100
"uniqueItems",
95101
]
96-
other_keywords = [
102+
other_keywords: ClassVar[list[str]] = [
97103
"format",
98104
"unevaluatedItems",
99105
"unevaluatedProperties",
@@ -103,12 +109,13 @@ class JSONSchemaLexer(RegexLexer):
103109
"format_assertion",
104110
]
105111

106-
tokens = {
112+
tokens: ClassVar[dict[str, list[Any]]] = {
107113
"whitespace": [
108114
(r"\s+", Token.Whitespace),
109115
],
110116
"data_types": [
111-
# Used Literal type here to differentiate the highlighted color of data types from other keywords
117+
# Used Literal type here to differentiate the highlighted
118+
# color of data types from other keywords
112119
(_get_regex_from_options(data_types), Token.Literal),
113120
],
114121
"core_keywords": [
@@ -186,7 +193,8 @@ class JSONSchemaLexer(RegexLexer):
186193
(r",", Token.Punctuation),
187194
(r"]", Token.Punctuation, "#pop"),
188195
],
189-
# a json value - either a simple value or a complex value (object or array)
196+
# a json value - either a simple value or a
197+
# complex value (object or array)
190198
"value": [
191199
include("whitespace"),
192200
include("simplevalue"),

0 commit comments

Comments
 (0)