ソースを参照

Switch to httpx (#74)

叶子 2 年 前
コミット
20286062d6
3 ファイル変更14 行追加68 行削除
  1. 4 58
      poetry.lock
  2. 9 9
      pynecone/pc.py
  3. 1 1
      pyproject.toml

+ 4 - 58
poetry.lock

@@ -104,21 +104,6 @@ files = [
     {file = "certifi-2022.12.7.tar.gz", hash = "sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3"},
 ]
 
-[[package]]
-name = "charset-normalizer"
-version = "2.1.1"
-description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet."
-category = "main"
-optional = false
-python-versions = ">=3.6.0"
-files = [
-    {file = "charset-normalizer-2.1.1.tar.gz", hash = "sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845"},
-    {file = "charset_normalizer-2.1.1-py3-none-any.whl", hash = "sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f"},
-]
-
-[package.extras]
-unicode-backport = ["unicodedata2"]
-
 [[package]]
 name = "click"
 version = "8.1.3"
@@ -414,14 +399,14 @@ files = [
 
 [[package]]
 name = "isort"
-version = "5.11.1"
+version = "5.11.2"
 description = "A Python utility / library to sort Python imports."
 category = "dev"
 optional = false
 python-versions = ">=3.7.0"
 files = [
-    {file = "isort-5.11.1-py3-none-any.whl", hash = "sha256:bf02c95f1fe615ebbe13a619cfed1619ddfe8941274c9e3de3143adca406cb02"},
-    {file = "isort-5.11.1.tar.gz", hash = "sha256:7c5bd998504826b6f1e6f2f98b533976b066baba29b8bae83fdeefd0b89c6b70"},
+    {file = "isort-5.11.2-py3-none-any.whl", hash = "sha256:e486966fba83f25b8045f8dd7455b0a0d1e4de481e1d7ce4669902d9fb85e622"},
+    {file = "isort-5.11.2.tar.gz", hash = "sha256:dd8bbc5c0990f2a095d754e50360915f73b4c26fc82733eb5bfc6b48396af4d2"},
 ]
 
 [package.extras]
@@ -703,28 +688,6 @@ typing-extensions = {version = "*", markers = "python_version < \"3.8\""}
 hiredis = ["hiredis (>=1.0.0)"]
 ocsp = ["cryptography (>=36.0.1)", "pyopenssl (==20.0.1)", "requests (>=2.26.0)"]
 
-[[package]]
-name = "requests"
-version = "2.28.1"
-description = "Python HTTP for Humans."
-category = "main"
-optional = false
-python-versions = ">=3.7, <4"
-files = [
-    {file = "requests-2.28.1-py3-none-any.whl", hash = "sha256:8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349"},
-    {file = "requests-2.28.1.tar.gz", hash = "sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983"},
-]
-
-[package.dependencies]
-certifi = ">=2017.4.17"
-charset-normalizer = ">=2,<3"
-idna = ">=2.5,<4"
-urllib3 = ">=1.21.1,<1.27"
-
-[package.extras]
-socks = ["PySocks (>=1.5.6,!=1.5.7)"]
-use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"]
-
 [[package]]
 name = "rfc3986"
 version = "1.5.0"
@@ -1037,23 +1000,6 @@ files = [
     {file = "typing_extensions-4.4.0.tar.gz", hash = "sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa"},
 ]
 
-[[package]]
-name = "urllib3"
-version = "1.26.13"
-description = "HTTP library with thread-safe connection pooling, file post, and more."
-category = "main"
-optional = false
-python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*"
-files = [
-    {file = "urllib3-1.26.13-py2.py3-none-any.whl", hash = "sha256:47cc05d99aaa09c9e72ed5809b60e7ba354e64b59c9c173ac3018642d8bb41fc"},
-    {file = "urllib3-1.26.13.tar.gz", hash = "sha256:c083dd0dce68dbfbe1129d5271cb90f9447dea7d52097c6e0126120c521ddea8"},
-]
-
-[package.extras]
-brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)", "brotlipy (>=0.6.0)"]
-secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "ipaddress", "pyOpenSSL (>=0.14)", "urllib3-secure-extra"]
-socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]
-
 [[package]]
 name = "uvicorn"
 version = "0.20.0"
@@ -1093,4 +1039,4 @@ testing = ["flake8 (<5)", "func-timeout", "jaraco.functools", "jaraco.itertools"
 [metadata]
 lock-version = "2.0"
 python-versions = "^3.7"
-content-hash = "4ebebcaa175467da4556ad4cf286b062f839dd8bd1f3f2cc7879580574894da2"
+content-hash = "bdbe03e00e254692c4037edb18af3f1c4be6562f95108c9f057691878d09885d"

+ 9 - 9
pynecone/pc.py

@@ -2,7 +2,7 @@
 
 import os
 
-import requests
+import httpx
 import typer
 
 from pynecone import constants, utils
@@ -40,7 +40,7 @@ def init():
             # Create a configuration file.
             with open(constants.CONFIG_FILE, "w") as f:
                 f.write(templates.PCCONFIG.format(app_name=app_name))
-                utils.console.log(f"Initialize the app directory.")
+                utils.console.log("Initialize the app directory.")
 
             # Initialize the app directory.
             utils.cp(constants.APP_TEMPLATE_DIR, app_name)
@@ -52,15 +52,15 @@ def init():
 
         # Install bun if it isn't already installed.
         if not os.path.exists(utils.get_bun_path()):
-            utils.console.log(f"Installing bun...")
+            utils.console.log("Installing bun...")
             os.system(constants.INSTALL_BUN)
 
         # Initialize the web directory.
-        utils.console.log(f"Initializing the web directory.")
+        utils.console.log("Initializing the web directory.")
         utils.rm(os.path.join(constants.WEB_TEMPLATE_DIR, constants.NODE_MODULES))
         utils.rm(os.path.join(constants.WEB_TEMPLATE_DIR, constants.PACKAGE_LOCK))
         utils.cp(constants.WEB_TEMPLATE_DIR, constants.WEB_DIR)
-        utils.console.log(f"[bold green]Finished Initializing: {app_name}")
+        utils.console.log("[bold green]Finished Initializing: {app_name}")
 
 
 @cli.command()
@@ -82,7 +82,7 @@ def run(
     # Check that the app is initialized.
     if not utils.is_initialized():
         utils.console.print(
-            f"[red]The app is not initialized. Run [bold]pc init[/bold] first."
+            "[red]The app is not initialized. Run [bold]pc init[/bold] first."
         )
         raise typer.Exit()
 
@@ -129,7 +129,7 @@ def deploy(dry_run: bool = False):
 
     # Deploy the app.
     data = {"userId": config.username, "projectId": config.app_name}
-    original_response = requests.get(config.deploy_url, params=data)
+    original_response = httpx.get(config.deploy_url, params=data)
     response = original_response.json()
     print("response", response)
     frontend = response["frontend_resources_url"]
@@ -137,10 +137,10 @@ def deploy(dry_run: bool = False):
 
     # Upload the frontend and backend.
     with open(constants.FRONTEND_ZIP, "rb") as f:
-        response = requests.put(frontend, data=f)
+        response = httpx.put(frontend, data=f)  # type: ignore
 
     with open(constants.BACKEND_ZIP, "rb") as f:
-        response = requests.put(backend, data=f)
+        response = httpx.put(backend, data=f)  # type: ignore
 
 
 main = cli

+ 1 - 1
pyproject.toml

@@ -28,12 +28,12 @@ fastapi = "^0.88.0"
 gunicorn = "^20.1.0"
 plotly = "^5.10.0"
 pydantic = "1.10.2"
-requests = "^2.28.1"
 sqlmodel = "^0.0.8"
 typer = "0.4.2"
 uvicorn = "^0.20.0"
 rich = "^12.6.0"
 redis = "^4.3.5"
+httpx = "^0.23.1"
 
 [tool.poetry.dev-dependencies]
 pytest = "^7.1.2"