cost 333 ms
如何使用 django-stubs 在摘要 Class 中鍵入自定義和覆蓋的管理器?

[英]How to typehint custom and overridden Managers in an Abstract Class using django-stubs?

我們正在嘗試將類型提示添加到我們的 django (3.2) 項目中。 我們正在使用 django-stubs (1.12.0)。 我們有一個帶有自定義BaseManager的AbstractBaseModel ,我們將其用於幾乎所有其他 model。在某些情況下,我們還擴展了自定義管理器。 例子 ...

沒有使用 Optional 就沒有定義 Mypy 抱怨名稱“Optional”

[英]Mypy complaining about Name "Optional" is not defined without the use of Optional

我最近開始使用 mypy,並且遇到了一些我一生都無法解決的奇怪問題。 我正在使用 mypy 0.950、django-stubs 1.11.0、django 4.0.5 和 python 3.10.2。 通過命令行運行 mypy 會返回: 然而, project/suppliers/mode ...

如何在 pyproject.tom 文件的 [tool.django-stubs] 指令中提供源目錄?

[英]How to provide a source directory in the [tool.django-stubs] directive of a pyproject.tom file?

我在我的 django 項目中使用src目錄作為根源目錄。 我正在嘗試使用 mypy 和 django-stubs 對那些 django 項目執行預提交操作。 是在 pyproject.toml 中比源根目錄在src/中的一種方式嗎? 現在,我有:pre-commit run --all ... ...

帶注釋字段的 Django model 的類型提示

[英]Type Hint for Django model with annotated field

假設我有以下 Django 型號: 我有一個 function 來獲取每個工具箱的所有小工具。 參數類型提示來自這個 SO 答案: 這里的想法是要求這個 function 的用戶使用prefetch_related()預取這個small_tools字段,以減少 db hits 的數量並加速代碼: 這 ...

VSCode 中的 Mypy linting 出現“構造 NewSemanalDRFPlugin 的插件實例時出錯”

[英]Mypy linting in VSCode Errors out with “Error constructing plugin instance of NewSemanalDRFPlugin”

嘗試在 VSCode 中運行 Mypy linter,總是在 output 中遇到相同的錯誤... Django項目的根目錄和工作區目錄不同。 mypy==0.770 mypy擴展==0.4.3 django-stubs==1.5.0 djangorestframework-stubs= ...

request.user 返回抽象用戶(django-stubs)

[英]request.user returning abstract user (django-stubs)

我正在嘗試輸入以下內容: 其中CustomUser是我在settings.py中定義的自定義用戶 model 。 我的 IDE 抱怨Expected type 'CustomUser', got 'AbstractBaseUser' instead 。 查看文檔,它說self.request.us ...

Django 存根中斷 Pycharm 自動競爭

[英]Django stubs interrupt Pycharm autocompete

我有一個帶有多個模型的 django 應用程序。 這是我過濾對象時的自動完成功能 然后我為 MyPy 安裝 django-stubs 現在我的自動完成看起來像這樣 當我刪除 django-stubs 時自動完成效果很好,就像第一張圖片一樣 那么,有沒有辦法將 django-stub ...


排序:
質量:
 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM