Repository: supakeen/pinnwand

Issue:
ModuleNotFoundError: No module named 'http.cookies'; 'http' is not a package
This error seems to happen particulary in `Pycharm` when I try to make a new config to run the `pinnwand` package with speciefic attributes to target the different CLI commands.

It first drove me crazy, but the issue is coming from a name conflict with the built-in Python `http` library .

Debugging is alot easier with `Pycharm`, at least to me. 

Would you be up to renaming the `http` module to `app`, since what it does eventually is make the app instance that'll later be ran.




Comments:

Patch:
diff --git a/requirements.txt b/requirements.txt
index 232a10f..639a635 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -428,9 +428,9 @@ iniconfig==2.0.0 \
 isort==5.13.2 \
     --hash=sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109 \
     --hash=sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6
-jinja2==3.1.2 \
-    --hash=sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852 \
-    --hash=sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61
+jinja2==3.1.3 \
+    --hash=sha256:7d6d50dd97d52cbc355597bd845fabfbac3f551e1f99619e39a35ce8c370b5fa \
+    --hash=sha256:ac8bd6544d4bb2c9792bf3a159e80bba8fda7f07e81bc3aed565432d5925ba90
 license-expression==30.1.1 \
     --hash=sha256:42375df653ad85e6f5b4b0385138b2dbea1f5d66360783d8625c3e4f97f11f0c \
     --hash=sha256:8d7e5e2de0d04fc104a4f952c440e8f08a5ba63480a0dad015b294770b7e58ec
diff --git a/src/pinnwand/http.py b/src/pinnwand/app.py
similarity index 100%
rename from src/pinnwand/http.py
rename to src/pinnwand/app.py
diff --git a/src/pinnwand/command.py b/src/pinnwand/command.py
index 969056a..dc9ec9a 100644
--- a/src/pinnwand/command.py
+++ b/src/pinnwand/command.py
@@ -82,7 +82,7 @@ def main(verbose: int, configuration_path: Optional[str]) -> None:
 def http(port: int, debug: bool) -> None:
     """Run pinnwand's HTTP server."""
     from pinnwand import utility
-    from pinnwand.http import make_application
+    from pinnwand.app import make_application
 
     # Reap expired pastes on startup (we might've been shut down for a while)
     utility.reap()


Test patch:
diff --git a/test/conftest.py b/test/conftest.py
index e79684f..9c4ed31 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -36,7 +36,7 @@ def pytest_runtest_makereport(item, call):
     outcome = yield
     screen_file = str(screenshot_dir / f"{slugify(item.nodeid)}.png")
     report = outcome.get_result()
-    extra = getattr(report, "extra", [])
+    extras = getattr(report, "extras", [])
     if report.when == "call":
         if report.failed:
             if "page" in item.funcargs:
@@ -44,8 +44,8 @@ def pytest_runtest_makereport(item, call):
                 make_screenshot(item, page)
         xfail = hasattr(report, "wasxfail")
         if (report.skipped and xfail) or (report.failed and not xfail):
-            extra.append(pytest_html.extras.png(re.sub("test\W*e2e\W*report\W*", "", screen_file)))
-        report.extra = extra
+            extras.append(pytest_html.extras.png(re.sub(r"test\W*e2e\W*report\W*", "", screen_file)))
+        report.extras = extras
 
 
 def make_screenshot(item, page):
diff --git a/test/integration/test_http_api.py b/test/integration/test_http_api.py
index 9b8df48..0f03f81 100644
--- a/test/integration/test_http_api.py
+++ b/test/integration/test_http_api.py
@@ -10,7 +10,7 @@ configuration.ratelimit["read"]["capacity"] = 2**64 - 1
 configuration.ratelimit["create"]["capacity"] = 2**64 - 1
 configuration.ratelimit["delete"]["capacity"] = 2**64 - 1
 
-from pinnwand import configuration, database, http, utility
+from pinnwand import configuration, database, app, utility
 
 
 class DeprecatedAPITestCase(tornado.testing.AsyncHTTPTestCase):
@@ -19,7 +19,7 @@ class DeprecatedAPITestCase(tornado.testing.AsyncHTTPTestCase):
         database.Base.metadata.create_all(database._engine)
 
     def get_app(self) -> tornado.web.Application:
-        return http.make_application()
+        return app.make_application()
 
     def test_api_new(self) -> None:
         response = self.fetch(
@@ -291,7 +291,7 @@ class APIv1TestCase(tornado.testing.AsyncHTTPTestCase):
         database.Base.metadata.create_all(database._engine)
 
     def get_app(self) -> tornado.web.Application:
-        return http.make_application()
+        return app.make_application()
 
     def test_api_new(self) -> None:
         response = self.fetch(
diff --git a/test/integration/test_http_curl.py b/test/integration/test_http_curl.py
index 08d0707..514fc08 100644
--- a/test/integration/test_http_curl.py
+++ b/test/integration/test_http_curl.py
@@ -10,7 +10,7 @@ configuration.ratelimit["read"]["capacity"] = 2**64 - 1
 configuration.ratelimit["create"]["capacity"] = 2**64 - 1
 configuration.ratelimit["delete"]["capacity"] = 2**64 - 1
 
-from pinnwand import database, http
+from pinnwand import database, app
 
 
 class CurlTestCase(tornado.testing.AsyncHTTPTestCase):
@@ -19,7 +19,7 @@ class CurlTestCase(tornado.testing.AsyncHTTPTestCase):
         database.Base.metadata.create_all(database._engine)
 
     def get_app(self) -> tornado.web.Application:
-        return http.make_application()
+        return app.make_application()
 
     def test_curl_post_no_lexer(self) -> None:
         response = self.fetch(
diff --git a/test/integration/test_http_website.py b/test/integration/test_http_website.py
index ffb2460..82cfb0e 100644
--- a/test/integration/test_http_website.py
+++ b/test/integration/test_http_website.py
@@ -9,7 +9,7 @@ configuration.ratelimit["read"]["capacity"] = 2**64 - 1
 configuration.ratelimit["create"]["capacity"] = 2**64 - 1
 configuration.ratelimit["delete"]["capacity"] = 2**64 - 1
 
-from pinnwand import database, http
+from pinnwand import database, app
 
 
 class WebsiteTestCase(tornado.testing.AsyncHTTPTestCase):
@@ -18,7 +18,7 @@ class WebsiteTestCase(tornado.testing.AsyncHTTPTestCase):
         database.Base.metadata.create_all(database._engine)
 
     def get_app(self) -> tornado.web.Application:
-        return http.make_application()
+        return app.make_application()
 
     def test_website_index(self) -> None:
         response = self.fetch(
@@ -402,7 +402,7 @@ class DeprecatedWebsiteTestCase(tornado.testing.AsyncHTTPTestCase):
         database.Base.metadata.create_all(database._engine)
 
     def get_app(self) -> tornado.web.Application:
-        return http.make_application()
+        return app.make_application()
 
     def test_website_index_post_no_lexer(self) -> None:
         response = self.fetch(