odc-cli crashes with "'staticmethod' object is not callable" on Python 3.8 and 3.9, which it claims to support

クローズ 初心者向け
#1,776 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

関連するプルリクエストがすでにマージされています。

  • #1841 @Sanilas-ai による — マージ済み

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
cli

調査の方向性

まず cli/odc-cli:58-68 と cli/odc-cli:300-302 周辺のハンドラーデコレーターを確認してください。cli/AGENTS.md には、サポート対象の Python バージョンとテストハーネスがないことが記載されています。コマンドクラス全体でデコレーターがどのように適用されているかを確認し、Python 3.8、3.9、および現行リリースで setup get-state、auth login、instruments list を検証してください。サポート対象のインタープリターで、これらのコマンドが報告された TypeError を発生させなくなれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Area: Infrastructure Bug Difficulty: Low Good First Issue Priority: Medium

On Python 3.8 and 3.9, odc-cli crashes with TypeError: 'staticmethod' object is not callable on every command that talks to the API. Each command handler is declared as @require_url (and often @require_token) stacked on @staticmethod. The decorators are applied in order, so require_url receives the staticmethod object itself, and its wrapper later calls fn(*args, **kwargs) on that object. A staticmethod object only became callable in Python 3.10 (bpo-43682). The script states that it targets Python 3.8: cli/AGENTS.md says so, and the file only hard-exits below 3.8. On the interpreters an administrator is most likely to have on a server or laptop, including macOS's /usr/bin/python3 (3.9.6), Debian 11 (3.9) and Ubuntu 20.04 (3.8), nothing works except config and the local auth logout and auth status. That includes auth login, setup, subjects, instrument-records and instruments.

Where

cli/odc-cli:58-68:

def require_url(fn: Callable[..., Any]) -> Callable[..., Any]:
    def wrapper(*args: Any, **kwargs: Any) -> None:
        # ...
        fn(*args, **kwargs)
    return wrapper

cli/odc-cli:300-302 (the same pattern is on every handler in AuthCommands, InstrumentRecordsCommands, SubjectCommands, InstrumentsCommands and SetupCommands):

class AuthCommands:
    @require_url
    @staticmethod
    def login(username: str, password: str) -> None:

Reproduce

  1. With Python 3.9 (for example macOS /usr/bin/python3), run python3 cli/odc-cli config set-url http://127.0.0.1:5500.
  2. Run python3 cli/odc-cli setup get-state.

Actual:

  File "cli/odc-cli", line 68, in wrapper
    fn(*args, **kwargs)
TypeError: 'staticmethod' object is not callable

Expected: the request is sent, as it is on Python 3.10 and later, where the same command prints the setup state or a network-error JSON.

Tests

cli/ has no test harness and nothing in CI runs it (cli/AGENTS.md). Verify the fix by running setup get-state, auth login and instruments list under Python 3.8, 3.9 and the current release, for example with uv run --python 3.8 cli/odc-cli setup get-state.

Suggested fix

Put @staticmethod outermost: write @staticmethod above @require_url and @require_token, so the auth decorators wrap the plain function. Alternatively, keep the order and unwrap inside the decorators with fn = fn.__func__ if isinstance(fn, staticmethod) else fn.

主要言語
TypeScript
スター
119
フォーク
19
平均マージ
5日 10時間
マージ済み PR(30日)
36

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

DouglasNeuroInformatics/OpenDataCapture のほかの issue

DouglasNeuroInformatics/OpenDataCapture の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。