Skip to content

Commit ac53f2f

Browse files
author
Gerit Wagner
committed
fix linter messages
1 parent d923a23 commit ac53f2f

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

search_query/ebscohost/parser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ class EBSCOListParser(QueryListParser):
431431
"""Parser for EBSCO (list format) queries."""
432432

433433
LIST_ITEM_REFERENCE = re.compile(r"S\d+|\#\d+")
434+
linter: EBSCOListLinter
434435

435436
def __init__(
436437
self,

search_query/linter.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,19 @@
1111
from search_query.search_file import SearchFile
1212

1313
if typing.TYPE_CHECKING:
14-
from search_query.parser_base import QueryStringParser
14+
from search_query.parser_base import QueryParserBase
1515
# pylint: disable=broad-except
1616

1717

1818
def _run_parser(
1919
search_string: str, *, platform: str, field_general: str
20-
) -> QueryStringParser:
20+
) -> QueryParserBase:
2121
"""Run the linter on the search string"""
2222

2323
platform = search_query.parser.get_platform(platform)
2424
version = search_query.parser.LATEST_VERSIONS[platform]
25+
26+
parser_class: type[QueryParserBase]
2527
if "1." in search_string:
2628
parser_class = search_query.parser.LIST_PARSERS[platform][version]
2729

search_query/parser_base.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,24 @@
1616
from search_query.query import Query
1717

1818
if typing.TYPE_CHECKING: # pragma: no cover
19-
from search_query.linter_base import QueryStringLinter
19+
from search_query.linter_base import QueryStringLinter, QueryListLinter
2020

2121

22-
class QueryStringParser(ABC):
22+
# pylint: disable=too-few-public-methods
23+
class QueryParserBase(ABC):
24+
"""
25+
QueryParserBase class
26+
"""
27+
28+
linter: QueryStringLinter | QueryListLinter
29+
30+
@abstractmethod
31+
def parse(self) -> Query:
32+
"""parser method"""
33+
raise NotImplementedError
34+
35+
36+
class QueryStringParser(QueryParserBase, ABC):
2337
"""Abstract base class for query string parsers"""
2438

2539
# Note: override the following:
@@ -200,12 +214,14 @@ def parse(self) -> Query:
200214
"""Parse the query."""
201215

202216

203-
class QueryListParser:
217+
class QueryListParser(QueryParserBase):
204218
"""QueryListParser"""
205219

206220
LIST_QUERY_LINE_REGEX: re.Pattern = re.compile(r"^\s*(\d+).\s+(.*)$")
207221
LIST_ITEM_REFERENCE = re.compile(r"#\d+")
208222

223+
linter: QueryListLinter
224+
209225
def __init__(
210226
self,
211227
query_list: str,

search_query/pubmed/parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ def parse(self) -> Query:
300300
class PubmedListParser(QueryListParser):
301301
"""Parser for Pubmed (list format) queries."""
302302

303+
linter: PubmedQueryListLinter
304+
303305
def __init__(
304306
self,
305307
query_list: str,

search_query/wos/parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ def parse(self) -> Query:
389389
class WOSListParser(QueryListParser):
390390
"""Parser for Web-of-Science (list format) queries."""
391391

392+
linter: WOSQueryListLinter
393+
392394
def __init__(
393395
self,
394396
query_list: str,

0 commit comments

Comments
 (0)