From c07703cc5882ef5e610f31b8224d49d1e9f3b8b3 Mon Sep 17 00:00:00 2001 From: awdem Date: Mon, 18 Nov 2024 16:07:54 +0000 Subject: [PATCH] ruff format --- eco_parser/__init__.py | 6 +++++- eco_parser/element_parsers.py | 11 ++++++++--- eco_parser/parser.py | 4 +++- setup.py | 5 ++++- tests/tests.py | 12 +++++++----- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/eco_parser/__init__.py b/eco_parser/__init__.py index d7e5edb..6756837 100644 --- a/eco_parser/__init__.py +++ b/eco_parser/__init__.py @@ -1,3 +1,7 @@ from eco_parser.core import ParseError -from eco_parser.element_parsers import BodyParser, ElementParserFactory, TableParser +from eco_parser.element_parsers import ( + BodyParser, + ElementParserFactory, + TableParser, +) from eco_parser.parser import EcoParser diff --git a/eco_parser/element_parsers.py b/eco_parser/element_parsers.py index a55cd15..9f48146 100644 --- a/eco_parser/element_parsers.py +++ b/eco_parser/element_parsers.py @@ -1,5 +1,10 @@ import abc -from eco_parser.core import NAMESPACES, get_single_element, get_child_text, ParseError +from eco_parser.core import ( + NAMESPACES, + get_single_element, + get_child_text, + ParseError, +) class ElementParser(metaclass=abc.ABCMeta): @@ -12,7 +17,6 @@ def parse(self): class TableParser(ElementParser): - FORMAT_UNKNOWN = 0 FORMAT_STANDARD_TABLE = 1 FORMAT_ONE_ROW_PARA = 2 @@ -60,7 +64,8 @@ def parse_one_row_table(self, tbody): for j in range(0, i): if len(data[j]) != expected_length: raise ParseError( - "Expected %i elements, found %i" % (expected_length, len(data[j])), + "Expected %i elements, found %i" + % (expected_length, len(data[j])), 0, ) diff --git a/eco_parser/parser.py b/eco_parser/parser.py index 61c7e29..63cbfe2 100644 --- a/eco_parser/parser.py +++ b/eco_parser/parser.py @@ -38,4 +38,6 @@ def parse(self): elif re.match(article_pattern, self.url): return self.parse_article() else: - raise ParseError("Could not find a suitable parser for %s" % (self.url), 0) + raise ParseError( + "Could not find a suitable parser for %s" % (self.url), 0 + ) diff --git a/setup.py b/setup.py index a79baeb..41138a9 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,10 @@ def _get_description(): long_description_content_type="text/markdown", entry_points={"console_scripts": ["eco_parser = eco_parser.__main__:main"]}, install_requires=["lxml", "requests"], - extras_require={"testing": ["coveralls"], "development": ["ruff==0.3.7"],}, + extras_require={ + "testing": ["coveralls"], + "development": ["ruff==0.3.7"], + }, classifiers=[ "License :: OSI Approved :: MIT License", "Programming Language :: Python", diff --git a/tests/tests.py b/tests/tests.py index 336ecbc..e68c2fa 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -21,9 +21,7 @@ ONE_ROW_TABLE_INVALID = ( "http://www.legislation.gov.uk/uksi/2016/657/schedule/1/made/data.xml" ) -UNKNOWN_TABLE_FORMAT = ( - "http://www.legislation.gov.uk/uksi/no-example-of-this/schedule/1/made/data.xml" -) +UNKNOWN_TABLE_FORMAT = "http://www.legislation.gov.uk/uksi/no-example-of-this/schedule/1/made/data.xml" # stub parser implementation we can run tests against @@ -96,8 +94,12 @@ def test_article_without_table(self): p = StubParser(ARTICLE_WITHOUT_TABLE) self.assertSequenceEqual( [ - ("The existing wards of the borough of Foo Town are abolished",), - ("The borough of Foo Town is divided into 5 wards as follows—",), + ( + "The existing wards of the borough of Foo Town are abolished", + ), + ( + "The borough of Foo Town is divided into 5 wards as follows—", + ), ("Crummock & Derwent Valley",), ("St John’s",), ("Warnell",),