mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-04 12:56:02 +00:00
style: introduce ruff as linter and formatter (#1356)
* style: remove necessary imports * style: fix F841 * style: fix F401 * style: fix F811 * style: fix E402 * style: fix E721 * style: fix E722 * style: fix E722 * style: fix F541 * style: ruff format * style: all passed * style: add ruff in deps * style: more ignores in ruff.toml * style: add pre-commit
This commit is contained in:
committed by
GitHub
parent
09e70d70e9
commit
209f16af76
@@ -1,14 +1,12 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from ..core import app
|
||||
|
||||
|
||||
class ProxyManager:
|
||||
"""代理管理器
|
||||
"""
|
||||
"""代理管理器"""
|
||||
|
||||
ap: app.Application
|
||||
|
||||
@@ -21,14 +19,24 @@ class ProxyManager:
|
||||
|
||||
async def initialize(self):
|
||||
self.forward_proxies = {
|
||||
"http://": os.getenv("HTTP_PROXY") or os.getenv("http_proxy"),
|
||||
"https://": os.getenv("HTTPS_PROXY") or os.getenv("https_proxy"),
|
||||
'http://': os.getenv('HTTP_PROXY') or os.getenv('http_proxy'),
|
||||
'https://': os.getenv('HTTPS_PROXY') or os.getenv('https_proxy'),
|
||||
}
|
||||
|
||||
if 'http' in self.ap.instance_config.data['proxy'] and self.ap.instance_config.data['proxy']['http']:
|
||||
self.forward_proxies['http://'] = self.ap.instance_config.data['proxy']['http']
|
||||
if 'https' in self.ap.instance_config.data['proxy'] and self.ap.instance_config.data['proxy']['https']:
|
||||
self.forward_proxies['https://'] = self.ap.instance_config.data['proxy']['https']
|
||||
if (
|
||||
'http' in self.ap.instance_config.data['proxy']
|
||||
and self.ap.instance_config.data['proxy']['http']
|
||||
):
|
||||
self.forward_proxies['http://'] = self.ap.instance_config.data['proxy'][
|
||||
'http'
|
||||
]
|
||||
if (
|
||||
'https' in self.ap.instance_config.data['proxy']
|
||||
and self.ap.instance_config.data['proxy']['https']
|
||||
):
|
||||
self.forward_proxies['https://'] = self.ap.instance_config.data['proxy'][
|
||||
'https'
|
||||
]
|
||||
|
||||
# 设置到环境变量
|
||||
os.environ['HTTP_PROXY'] = self.forward_proxies['http://'] or ''
|
||||
|
||||
Reference in New Issue
Block a user