From e86d55c9d6dde67086a55c5fba22806482b3fb4b Mon Sep 17 00:00:00 2001 From: nannan00 <17491932+nannan00@users.noreply.github.com> Date: Mon, 29 Jul 2024 19:55:14 +0800 Subject: [PATCH] fix: mypy --- .github/workflows/bk-login.yml | 9 +++------ .github/workflows/bk-user.yml | 9 +++------ .pre-commit-config.yaml | 2 +- src/bk-login/bklogin/component/http.py | 16 ++++++++++------ src/idp-plugins/idp_plugins/http.py | 2 +- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/.github/workflows/bk-login.yml b/.github/workflows/bk-login.yml index 11671dcfb..4ca2e102e 100644 --- a/.github/workflows/bk-login.yml +++ b/.github/workflows/bk-login.yml @@ -56,16 +56,13 @@ jobs: uses: actions/setup-python@v4 with: python-version: "3.10" + cache: 'pip' + cache-dependency-path: 'src/bk-login/requirements_dev.txt' - name: create idp plugin symbolic link run: | ln -s $(pwd)/src/idp-plugins/idp_plugins $(pwd)/src/bk-login/bklogin - - name: Set up Poetry - uses: abatilo/actions-poetry@v2.3.0 - with: - poetry-version: "1.6.1" - name: Install dependencies - working-directory: src/bk-login - run: poetry install + run: pip install -r src/bk-login/requirements_dev.txt - name: Run unittest working-directory: src/bk-login run: | diff --git a/.github/workflows/bk-user.yml b/.github/workflows/bk-user.yml index 3931aa406..d4ec48495 100644 --- a/.github/workflows/bk-user.yml +++ b/.github/workflows/bk-user.yml @@ -56,16 +56,13 @@ jobs: uses: actions/setup-python@v5 with: python-version: "3.10" + cache: 'pip' + cache-dependency-path: 'src/bk-user/requirements_dev.txt' - name: create idp plugin symbolic link run: | ln -s $(pwd)/src/idp-plugins/idp_plugins $(pwd)/src/bk-user/bkuser - - name: Set up Poetry - uses: abatilo/actions-poetry@v2.3.0 - with: - poetry-version: "1.5.1" - name: Install dependencies - working-directory: src/bk-user - run: poetry install + run: pip install -r src/bk-user/requirements_dev.txt - name: Run unittest working-directory: src/bk-user run: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 06c23b3d2..0f46f897d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -136,7 +136,7 @@ repos: name: ruff language: python types: [python] - entry: ruff --config=src/idp-plugins/pyproject.toml --fix --no-cache + entry: ruff check --config=src/idp-plugins/pyproject.toml --fix --no-cache files: src/idp-plugins/ - id: mypy name: mypy diff --git a/src/bk-login/bklogin/component/http.py b/src/bk-login/bklogin/component/http.py index 6a9f38966..3d045b668 100644 --- a/src/bk-login/bklogin/component/http.py +++ b/src/bk-login/bklogin/component/http.py @@ -8,6 +8,7 @@ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ + import logging import time from typing import Dict, Tuple @@ -127,12 +128,15 @@ def _http_request(method: str, url: str, **kwargs) -> Tuple[HttpStatusCode, Dict resp.status_code, content, ) - return INVALID_JSON_STATUS_CODE, { - "error": ( - f"http response body not json, http status code is {resp.status_code}! " - f"{method} {urlparse(url).path}, response.body={content}, error:{e}" - ) - } + return ( + INVALID_JSON_STATUS_CODE, + { + "error": ( + f"http response body not json, http status code is {resp.status_code}! " # type: ignore + f"{method} {urlparse(url).path}, response.body={content}, error:{e}" + ) + }, + ) def _http_request_only_20x(method: str, url: str, **kwargs) -> Tuple[bool, Dict]: diff --git a/src/idp-plugins/idp_plugins/http.py b/src/idp-plugins/idp_plugins/http.py index 2048f00e8..49a87a6da 100644 --- a/src/idp-plugins/idp_plugins/http.py +++ b/src/idp-plugins/idp_plugins/http.py @@ -130,7 +130,7 @@ def _http_request(method: str, url: str, **kwargs) -> Tuple[HttpStatusCode, Dict ) return INVALID_JSON_STATUS_CODE, { "error": ( - f"http response body not json, http status code is {resp.status_code}! " + f"http response body not json, http status code is {resp.status_code}! " # type: ignore f"{method} {urlparse(url).path}, response.body={content}, error:{e}" ) }