From 8515d2edd70fc16d69aa7b1094f9b3534dfa74d9 Mon Sep 17 00:00:00 2001 From: Simon Heisterkamp Date: Wed, 30 Nov 2022 15:00:03 +0000 Subject: remove type annotations for python 3.5 compatibility --- sqlparse/keywords.py | 6 ------ sqlparse/lexer.py | 8 ++------ tests/test_parse.py | 1 - 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/sqlparse/keywords.py b/sqlparse/keywords.py index ce53781..6bc7937 100644 --- a/sqlparse/keywords.py +++ b/sqlparse/keywords.py @@ -6,18 +6,12 @@ # the BSD License: https://opensource.org/licenses/BSD-3-Clause import re -from typing import Dict, List, Tuple, Callable, Union from sqlparse import tokens # object() only supports "is" and is useful as a marker PROCESS_AS_KEYWORD = object() -SQL_REGEX_TYPE = List[ - Tuple[Callable, Union[type(PROCESS_AS_KEYWORD), tokens._TokenType]] -] -KEYWORDS_TYPE = Dict[str, tokens._TokenType] - SQL_REGEX = { 'root': [ diff --git a/sqlparse/lexer.py b/sqlparse/lexer.py index 61c52a9..7408e01 100644 --- a/sqlparse/lexer.py +++ b/sqlparse/lexer.py @@ -13,7 +13,6 @@ # and to allow some customizations. from io import TextIOBase -from typing import List from sqlparse import tokens, keywords from sqlparse.utils import consume @@ -34,9 +33,6 @@ class Lexer(metaclass=_LexerSingletonMetaclass): """The Lexer supports configurable syntax. To add support for additional keywords, use the `add_keywords` method.""" - _SQL_REGEX: keywords.SQL_REGEX_TYPE - _keywords: List[keywords.KEYWORDS_TYPE] - def default_initialization(self): """Initialize the lexer with default dictionaries. Useful if you need to revert custom syntax settings.""" @@ -58,11 +54,11 @@ class Lexer(metaclass=_LexerSingletonMetaclass): self._SQL_REGEX = [] self._keywords = [] - def set_SQL_REGEX(self, SQL_REGEX: keywords.SQL_REGEX_TYPE): + def set_SQL_REGEX(self, SQL_REGEX): """Set the list of regex that will parse the SQL.""" self._SQL_REGEX = SQL_REGEX - def add_keywords(self, keywords: keywords.KEYWORDS_TYPE): + def add_keywords(self, keywords): """Add keyword dictionaries. Keywords are looked up in the same order that dictionaries were added.""" self._keywords.append(keywords) diff --git a/tests/test_parse.py b/tests/test_parse.py index c5dfd36..3018d9a 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -494,7 +494,6 @@ def test_parenthesis(): def test_configurable_syntax(): sql = """select * from foo BACON SPAM EGGS;""" - # sql="""select * from mydb.mytable BACON SPAM EGGS;""" tokens = sqlparse.parse(sql)[0] assert list( -- cgit v1.2.1