diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 0541354..524ca6a 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -19,20 +19,20 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: - # “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录 + # "最近更新时间" 等 git 日志相关信息,需要拉取全部提交记录 fetch-depth: 0 - name: Setup Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: # 选择要使用的 node 版本 - node-version: '18.8.0' + node-version: '20' - name: Install pnpm - uses: pnpm/action-setup@v2 + uses: pnpm/action-setup@v4 with: - version: 7.17.0 + version: 9 # 如果缓存没有命中,安装依赖 - name: Install dependencies run: pnpm install --dir docs @@ -44,7 +44,7 @@ jobs: # 查看 workflow 的文档来获取更多信息 # @see https://github.com/crazy-max/ghaction-github-pages - name: Deploy to GitHub Pages - uses: crazy-max/ghaction-github-pages@v2 + uses: crazy-max/ghaction-github-pages@v4 with: # 部署到 gh-pages 分支 target_branch: gh-pages diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9e3b5d8..6db7e5d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,12 +11,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - name: Set up Python 3.10 - uses: actions/setup-python@v4 + - name: Set up Python 3.12 + uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.12" - name: Install Poetry uses: snok/install-poetry@v1 @@ -32,7 +32,8 @@ jobs: id: check-version run: | [[ "$(poetry version --short)" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] \ - || echo ::set-output name=prerelease::true + && echo "prerelease=false" >> $GITHUB_OUTPUT \ + || echo "prerelease=true" >> $GITHUB_OUTPUT - name: Create Release uses: ncipollo/release-action@v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 151d134..4960d08 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,12 +11,12 @@ jobs: fail-fast: true matrix: os: [ "ubuntu-latest" ] - python-version: [ "3.8", "3.9", "3.10" ] + python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install Poetry diff --git a/pyproject.toml b/pyproject.toml index 9781097..50864ed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,11 +10,8 @@ packages = [ ] [tool.poetry.dependencies] -python = "^3.7" -typing-extensions = [ - { version = "^4.0.0", python = ">=3.6,<3.7" }, - { version = "^4.5.0", python = ">=3.7" } -] +python = "^3.8" +typing-extensions = "^4.5.0" [tool.poetry.group.test.dependencies] @@ -27,9 +24,11 @@ ruff = "*" pre-commit = "*" pre-commit-hooks = "*" -[tool.ruff] +[tool.ruff.lint] ignore = [ "E501", # line too long, handled by black + "F403", # star imports + "F405", # may be undefined from star imports ] [build-system] diff --git a/src/usepy/decorator/throttle.py b/src/usepy/decorator/throttle.py index 8e73ab4..69f59ff 100644 --- a/src/usepy/decorator/throttle.py +++ b/src/usepy/decorator/throttle.py @@ -20,7 +20,6 @@ def __init__(self, delay: int): def __call__(self, func): @wraps(func) def wrapper(*args, **kwargs): - nonlocal self current_time = time.time() if current_time - self.last_called >= self.delay: result = func(*args, **kwargs) diff --git a/src/usepy/list/flatten.py b/src/usepy/list/flatten.py index f921129..aff8e2b 100644 --- a/src/usepy/list/flatten.py +++ b/src/usepy/list/flatten.py @@ -1,4 +1,4 @@ -from typing import TypeVar, List, Union, Optional +from typing import TypeVar, List, Union T = TypeVar("T") D = TypeVar("D", int, float) diff --git a/src/usepy/misc/dynamic_import.py b/src/usepy/misc/dynamic_import.py index fdf5d79..c874c4d 100644 --- a/src/usepy/misc/dynamic_import.py +++ b/src/usepy/misc/dynamic_import.py @@ -23,7 +23,7 @@ def dynamic_import(module_string: str): function_name = "" module = importlib.import_module(module_string) except Exception as e: - raise ImportError(f"无法导入 {module_string}") + raise ImportError(f"无法导入 {module_string}: {e}") from e function = getattr(module, function_name, None) return module, function diff --git a/src/usepy/typing_.py b/src/usepy/typing_.py index 9aa6ce4..b22131d 100644 --- a/src/usepy/typing_.py +++ b/src/usepy/typing_.py @@ -5,3 +5,5 @@ from typing import Union else: from typing_extensions import Union + +__all__ = ["Union"]