python / python/mypy

Different behaviour of 1.0.0 wheels from pypi

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

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

bug
Ngôn ngữ chính
Python
Star
20.6k
Fork
3.3k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

Hello,

I noticed that the manylinux_2_17_x86_64.manylinux2014_x86_64 and py3-none-any pypi wheels behave differently.

Bug Report

...but I don't know specifically what the issue is 😬
I wrote a mypy plugin. It used to work correctly with mypy 0.920-0.991. Then the tests started failing in CI when 1.0.0 was released. I've easily reproduced that locally. Wanted to get to the bottom of it, so downloaded mypy source, checked out v1.0.0, installed the local package and... the tests passed.
I've only later discovered that when I use the py3-none-any wheel from pypi it also works as expected.

The plugin hooks into get_type_analyze_hook, get_method_signature_hook and get_function_signature_hook modifying instances of a specific class (joining Protocols together). I understand this is no place to seek help in my project, but I believe the issue is with these particular distributions and not on my end, since everything works correctly when using the source or the generic wheel.

Locally I'm testing everything with python 3.10.9, but I've also confirmed this is the case with 3.11.1 and it failed with 3.7.15 in CI (Github Actions).

To Reproduce

I wish I could provide a simpler example, but I'm afraid I can't. I've tried narrowing the issue down, but couldn't do it with a compiled version of mypy and the source version works beautifully 😬 .

git clone https://github.com/klausweiss/typing-protocol-intersection.git --branch mypy-1.0.0
cd typing-protocol-intersection
python -m venv venv-manylinux
source venv-manylinux/bin/activate
pip download mypy==1.0.0 --platform=manylinux_2_17_x86_64 --only-binary=:all: 
pip install *.whl
mypy --config-file tests/test-mypy.ini tests/testcases/in_generic_param_unhappy_path.py --no-incremental

Outcome is

tests/testcases/in_generic_param_unhappy_path.py:49:15: error: Argument 1 to "get_x_y_1" has incompatible type "ProtocolIntersection[HasX]"; expected "DesiredObject"  [arg-type]
tests/testcases/in_generic_param_unhappy_path.py:49:15: note: "ProtocolIntersection" is missing following "DesiredObject" protocol member:
tests/testcases/in_generic_param_unhappy_path.py:49:15: note:     y
Found 1 error in 1 file (checked 1 source file)

Expected Behavior

Outcome:

tests/testcases/in_generic_param_unhappy_path.py:49:15: error: Argument 1 to "get_x_y_1" has incompatible type "ProtocolIntersection[HasX]"; expected "DesiredObject"  [arg-type]
tests/testcases/in_generic_param_unhappy_path.py:49:15: note: "ProtocolIntersection" is missing following "DesiredObject" protocol member:
tests/testcases/in_generic_param_unhappy_path.py:49:15: note:     y
tests/testcases/in_generic_param_unhappy_path.py:50:15: error: Argument 1 to "get_x_y_2" has incompatible type "typing_protocol_intersection.types.ProtocolIntersection[HasX]"; expected "typing_protocol_intersection.types.ProtocolIntersection[HasY, HasX]"  [arg-type]
tests/testcases/in_generic_param_unhappy_path.py:50:15: note: "ProtocolIntersection" is missing following "ProtocolIntersection" protocol member:
tests/testcases/in_generic_param_unhappy_path.py:50:15: note:     y
Found 2 errors in 1 file (checked 1 source file)

You get the expected outcome when you follow the same steps as above, but downloading a py3-any-none wheel instead:

git clone https://github.com/klausweiss/typing-protocol-intersection.git --branch mypy-1.0.0
cd typing-protocol-intersection
python -m venv venv-manylinux
source venv-manylinux/bin/activate
pip download mypy==1.0.0 --platform=none --only-binary=:all: 
pip install *.whl
mypy --config-file tests/test-mypy.ini tests/testcases/in_generic_param_unhappy_path.py --no-incremental

Again, that's also the behavior I observed when cloning the mypy repo, checking out v1.0.0, and installing from a local directory.

Actual Behavior

See the To Reproduce section.

Your Environment

  • Mypy version used: v1.0.0
  • Mypy command-line flags: --no-incremental --config-file tests/test-mypy.ini
  • Mypy configuration options from mypy.ini (and other config files):
    • contents of tests/test-mypy.ini:
      [mypy]
      plugins = ../typing_protocol_intersection/mypy_plugin.py
      check_untyped_defs = True
      disallow_any_generics = True
      disallow_any_unimported = True
      disallow_incomplete_defs = True
      disallow_subclassing_any = True
      disallow_untyped_calls = True
      disallow_untyped_decorators = True
      disallow_untyped_defs = True
      implicit_reexport = False
      no_implicit_optional = True
      show_column_numbers = True
      show_error_codes = True
      strict_equality = True
      strict_optional = True
      warn_no_return = True
      warn_redundant_casts = True
      warn_return_any = True
      warn_unused_configs = True
      
  • Python version used: 3.10.9 but also with 3.11.1 and 3.7.15, haven't checked any others
  • OS: Manjaro Linux 5.15.91, glibc version 2.36

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.

Hướng nghiên cứu

Bắt đầu với bản tái hiện typing-protocol-intersection được liên kết và branch mypy-1.0.0 của nó. Chạy các lệnh pip download và mypy được cung cấp cho các wheel manylinux và py3-none-any, sau đó so sánh các kết quả đó với một source checkout. Công việc được xem là hoàn tất khi hành vi đặc thù của distribution đã được giải thích và bản tái hiện được báo cáo không còn khác biệt ngoài dự kiến.

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

Đánh giá

Công nghệ
python
Lĩnh vực
devtools
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
35/100

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.