Complete library typing and enforce mypy strict in CI

Đang mở
#722 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
ci-cd, tooling

Hướng nghiên cứu

Bắt đầu bằng cách tái tạo baseline chỉ dành cho thư viện với checkout đã được ghim và mypy --strict, tách tám package thư viện khỏi client kiểm tra được tạo tự động. Xem xét các export bị thiếu, annotation chưa đầy đủ, lệnh gọi không có kiểu và đối số generic bị thiếu đã được báo cáo, sau đó kiểm tra các wheel đã cài đặt để tìm py.typed và các import của consumer. Công việc được xem là hoàn tất khi cả tám package đều vượt qua các kiểm tra strict trong CI, các wheel có kiểu hỗ trợ các kiểm tra tiêu biểu của consumer và các bài kiểm tra runtime hiện có vẫn tiếp tục đạt.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Hi! I use LLMs to help write code, and passing strict type checks such as mypy --strict is one of my guardrails. A project I'm working on depends on this library, so more complete type information would save me a lot of troubleshooting and help catch mistakes earlier.

Is your feature request related to a problem? Please describe.

The library already has substantial type annotations and runs mypy in CI. However, strict checking still exposes gaps that affect consumers. On the checkout described below, ordinary mypy passes, while mypy --strict reports 298 errors across the eight library packages.

For example, checking this consumer code with mypy --strict example.py reports implicit-export errors for both imports, an untyped call to get_key(), and an Any return:

from kiota_abstractions.serialization import Parsable
from kiota_http.middleware.options import RetryHandlerOption


def retry_option_key() -> str:
    return RetryHandlerOption().get_key()

I also built the microsoft-kiota-bundle wheel locally and confirmed that it lacks py.typed. Mypy treats an installed import of kiota_bundle.default_request_adapter as untyped, despite the annotations in its source.

Describe the solution you'd like

Complete the existing typing support and enforce strict mypy checks for the library packages.

Suggested definition of done:

  • All eight library source packages pass mypy --strict in CI with a pinned mypy version across the supported Python versions.
  • Consumer checks against installed wheels verify public imports and representative inferred return types; all intended typed packages ship py.typed.
  • Public types remain useful, with any necessary suppressions narrowly scoped and explained, rather than broadly replacing types with Any or disabling checks.
  • Existing runtime tests pass and public behavior remains compatible.

I suggest keeping unit-test typing and adopting another checker outside the initial scope. Recurring generated-code annotation changes could be tracked separately with the generator work they require.

Describe alternatives you've considered

Local stubs or per-project mypy overrides could work around individual problems, but would leave consumers maintaining those workarounds. Completing the shared library annotations would benefit dependent projects directly.

Additional context

  • Checkout: eef36d7e72197063f234b24407edad15ad873bea; local packages report version 1.12.1.
  • Environment: Linux, Python 3.13.5, mypy 2.3.1; dependencies installed using uv, with all eight packages installed in editable mode.
  • The library-only baseline is 298 errors in 101 checked source files. The generated validation client adds 345 errors in 86 files; those are separate from the library count.
  • The largest recurring library categories are missing explicit exports, incomplete function annotations, untyped calls, and missing generic arguments.
  • Related earlier typing discussions: #355 and #333, both closed.

Would you be open to using strict mypy compliance as a tracked enhancement for the library packages?

Ngôn ngữ chính
Python
Star
31
Fork
39
Merge trung bình
11 giờ 45 phút
Pull request đã merge (30 ngày)
42

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/kiota-python

Tất cả issue của microsoft/kiota-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.