Skip to content

Commit

Permalink
Add docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
briantu committed Nov 6, 2024
1 parent abc689e commit 1a559e3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from antlr4 import CommonTokenStream, InputStream

from dagster._annotations import experimental
from dagster._core.definitions.antlr_asset_selection.generated.AssetSelectionLexer import (
AssetSelectionLexer,
)
Expand All @@ -8,6 +9,7 @@
)


@experimental
class AntlrAssetSelection:
def __init__(self, selection_str: str):
lexer = AssetSelectionLexer(InputStream(selection_str))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
def fix_imports(file_path):
"""This function fixes the imports in the files generated by ANTLR.
Some files have imports that check for older python versions which
causes issues with the linter. This function removes the if/else check
and only keeps the import statement that works for our python version.
"""
with open(file_path, "r") as file:
lines = file.readlines()
updated_lines = []
Expand All @@ -16,6 +21,10 @@ def fix_imports(file_path):


def add_lines_to_start(file_path, lines_to_add):
"""This function adds lines to the start of a file. This is used to
add `flake8: noqa` and `type: ignore` to the files generated by ANTLR
to ignore linter errors caused by ANTLR.
"""
with open(file_path, "r") as file:
original_content = file.readlines()

Expand All @@ -35,7 +44,7 @@ def add_lines_to_start(file_path, lines_to_add):
for file in files:
fix_imports(file)
add_lines_to_start(file, ["# flake8: noqa\n"])
if file == "AssetSelectionParser.py":
if file == "generated/AssetSelectionParser.py":
add_lines_to_start(
file,
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# type: ignore
# flake8: noqa
# Generated from AssetSelection.g4 by ANTLR 4.13.2
# encoding: utf-8
Expand Down

0 comments on commit 1a559e3

Please sign in to comment.