diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml
index e4a02e0..f0b2e45 100644
--- a/.github/workflows/python-app.yml
+++ b/.github/workflows/python-app.yml
@@ -36,7 +36,7 @@ jobs:
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
- flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
+ flake8 . --count --exit-zero --max-complexity=15 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest --cov-fail-under=100 -o xfail_strict=true --cov-report=term-missing .
diff --git a/src/bootstraparse/modules/context_mngr.py b/src/bootstraparse/modules/context_mngr.py
index 346fd2a..e3ceb0e 100644
--- a/src/bootstraparse/modules/context_mngr.py
+++ b/src/bootstraparse/modules/context_mngr.py
@@ -11,7 +11,6 @@
# container = BaseContainer()
# container[number] -> The number element in the content
# "class_insert" >> container[number] -> Get an element from one of the mapped methods
-import rich
from bootstraparse.modules import syntax, error_mngr, export
from bootstraparse.modules.error_mngr import MismatchedContainerError, log_exception, log_message, LonelyOptionalError # noqa
@@ -316,7 +315,6 @@ class LinebreakContainer(BaseContainer):
return "
\n"*(len(self.content)-1)
-
"""
Dictionary of all correspondences between tokens and containers.
"""
@@ -444,8 +442,8 @@ class ContextManager:
# self.pile = self.parsed_list.copy()
if self.contextualised:
return self.pile
- index = 0
- line_number = 1
+
+ index, line_number = 0, 1
while index < len(self.parsed_list):
token = self.parsed_list[index]
@@ -521,7 +519,10 @@ class ContextManager:
line = "Undefined"
name = "Undefined"
log_exception(
- TypeError(f"Encountered a non-container element in the pile during the final pass: {p}, at line {line} in file {name}."),
+ TypeError(
+ f"Encountered a non-container element in the pile during "
+ f"the final pass: {p}, at line {line} in file {name}."
+ ),
level="CRITICAL"
)
self.pile = final_pile
diff --git a/src/bootstraparse/modules/error_mngr.py b/src/bootstraparse/modules/error_mngr.py
index 1fd5a12..9b446d2 100644
--- a/src/bootstraparse/modules/error_mngr.py
+++ b/src/bootstraparse/modules/error_mngr.py
@@ -182,7 +182,8 @@ class LonelyOptionalError(BootstraparseError):
self.name = None
if last_in_pile:
super().__init__(f"Could not match token {token} at line {self.line} with "
- f"last element in pile {last_in_pile} at line {last_in_pile.line_number} in file {self.name}(not a container).")
+ f"last element in pile {last_in_pile} at line {last_in_pile.line_number} "
+ f"in file {self.name}(not a container).")
else:
super().__init__(f"Could not match token {token} at line {self.line} in file {self.name}"
f"as there was nothing in the pile.")
diff --git a/src/bootstraparse/modules/preparser.py b/src/bootstraparse/modules/preparser.py
index f31e285..47392ec 100644
--- a/src/bootstraparse/modules/preparser.py
+++ b/src/bootstraparse/modules/preparser.py
@@ -248,7 +248,8 @@ class PreParser:
validated_elements.append(f'[{key}]')
except KeyError:
error_mngr.log_exception(
- KeyError(f"Could not find key {key} in dict config{''.join(validated_elements)} in configs {'; '.join(self._env.config.config_folders)}"),
+ KeyError(f"Could not find key {key} in dict config{''.join(validated_elements)} "
+ f"in configs {'; '.join(self._env.config.config_folders)}"),
level='CRITICAL'
)
return sub_dict
diff --git a/src/bootstraparse/modules/sitecrawler.py b/src/bootstraparse/modules/sitecrawler.py
index eea452d..4470dac 100644
--- a/src/bootstraparse/modules/sitecrawler.py
+++ b/src/bootstraparse/modules/sitecrawler.py
@@ -33,7 +33,6 @@ class SiteCrawler:
def get_all_paths(self):
self.files, self.directories = self.list_recursively(self.initial_path, self.initial_path)
- print (self.files, self.directories)
def list_recursively(self, path, root):
files = []
diff --git a/src/bootstraparse/modules/sitecreator.py b/src/bootstraparse/modules/sitecreator.py
index 5194403..67494cc 100644
--- a/src/bootstraparse/modules/sitecreator.py
+++ b/src/bootstraparse/modules/sitecreator.py
@@ -1,8 +1,6 @@
# Module sequencing the successive actions necessary for website building
import os
-import rich
-
from bootstraparse.modules import pathresolver, sitecrawler, environment, config, export, parser, context_mngr
diff --git a/tests/modules/test_context_mngr.py b/tests/modules/test_context_mngr.py
index 7877753..895cbd6 100644
--- a/tests/modules/test_context_mngr.py
+++ b/tests/modules/test_context_mngr.py
@@ -678,3 +678,6 @@ def test_finalize_pile(base_cm):
base_cm.pile[0] = {}
with pytest.raises(TypeError):
base_cm.finalize_pile()
+ base_cm.pile[0] = sy.TextToken(['e'])
+ with pytest.raises(TypeError):
+ base_cm.finalize_pile()
diff --git a/tests/modules/test_preparser.py b/tests/modules/test_preparser.py
index fca683a..dec0fb9 100644
--- a/tests/modules/test_preparser.py
+++ b/tests/modules/test_preparser.py
@@ -44,7 +44,7 @@ Test content line 7
"""
content_page1 = """Test page1\nTest page1-2\nTest page1-3\n"""
content_page2 = """Test page2\n::< page1.bpr >"""
-content_page3 = """Test page3\n::< subpages/page3.bpr > < subpages/spage4.bpr > < page4.bpr >"""
+content_page3 = """Test page3\n::< subpages/page3.bpr > < subpages/spage4.bpr > < page4.bpr >""" # noqa: E501
content_page4 = """Test page4\n::< page5.bpr > < page6.bpr > < ../index.bpr >"""
content_page5 = """Test page5\n::"""
content_page6 = """Test page6\n::"""
@@ -401,5 +401,5 @@ def test_make_replacement_errors():
assert pp.make_replacements("This is a test", "not_existing") == "This is a test"
assert pp.make_replacements("This is a test {}", "shortcuts") == "This is a test shortcuts"
assert pp.make_replacements("This is a test {}", "images") == "This is a test images"
- assert pp.make_replacements("This is a test {} {} {image} {b}", 1, 2, image="images", b="b") == "This is a test 1 2 images b"
+ assert pp.make_replacements("This is a test {} {} {image} {b}", 1, 2, image="images", b="b") == "This is a test 1 2 images b" # noqa: E501
assert pp.make_replacements("This is a test {} {} {image} {b}", karm=3) == "This is a test {} {} {image} {b}"
diff --git a/tests/modules/test_sitecrawler.py b/tests/modules/test_sitecrawler.py
index 1e6263b..5602f75 100644
--- a/tests/modules/test_sitecrawler.py
+++ b/tests/modules/test_sitecrawler.py
@@ -16,7 +16,7 @@ files = [
("base/_noimport.bpr", "", ""),
("base/subtests/test4.bpr", "", ""),
("base/subtests/test5.bpr", "", ""),
- ("base/config/test6.yml", "", None),
+ ("base/config/test6.bpr", "", None),
("base/config/test7.yml", "", None),
("base/templates/test8.yml", "", None),
]
@@ -38,7 +38,8 @@ def list_files():
"""
List all files in the test directory
"""
- return [(os.path.join(_DEST, make_new_file(file, content).split("/", 1)[1].replace(".bpr", ".html")), exp) for file, content, exp in files]
+ return [(os.path.join(_DEST, make_new_file(file, content).split("/", 1)[1].replace(".bpr", ".html")), exp)
+ for file, content, exp in files]
@pytest.fixture(scope="module")
diff --git a/tests/modules/test_sitecreator.py b/tests/modules/test_sitecreator.py
index 51667fe..a074186 100644
--- a/tests/modules/test_sitecreator.py
+++ b/tests/modules/test_sitecreator.py
@@ -37,7 +37,8 @@ def list_files():
"""
List all files in the test directory
"""
- return [(os.path.join(_DEST, make_new_file(file, content).split("/", 1)[1].replace(".bpr", ".html")), exp) for file, content, exp in files]
+ return [(os.path.join(_DEST, make_new_file(file, content).split("/", 1)[1].replace(".bpr", ".html")), exp)
+ for file, content, exp in files]
@pytest.fixture(scope="module")
diff --git a/tests/modules/test_syntax.py b/tests/modules/test_syntax.py
index 53f0f89..a3e8ad4 100644
--- a/tests/modules/test_syntax.py
+++ b/tests/modules/test_syntax.py
@@ -4,7 +4,7 @@ import pyparsing
import pytest
import bootstraparse.modules.syntax as sy
-from bootstraparse.modules.tools import __GL, __module_path, find_variables_in_file # , find_functions_in_file, find_classes_in_file
+from bootstraparse.modules.tools import __GL, __module_path, find_variables_in_file
ptp = pytest.param
__XF = pytest.mark.xfail