Skip to content

Enable support for decorated properties where possible #13409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 14, 2022

Conversation

ilevkivskyi
Copy link
Member

Fixes #1362

This is based on the original idea by @graingert. I delete the old cryptic error message and instead:

  • Enable the situations that we can already handle (cover 95% of what was discussed in the issue)
  • For the rest give more precise error messages

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

twine (https://github.com/pypa/twine)
+ twine/auth.py:31: error: Unused "type: ignore" comment
+ twine/auth.py:41: error: Unused "type: ignore" comment

spark (https://github.com/apache/spark)
+ python/pyspark/sql/session.py:447: error: Unused "type: ignore" comment
+ python/pyspark/sql/session.py:453: error: Unused "type: ignore" comment
+ python/pyspark/sql/session.py:459: error: Unused "type: ignore" comment
+ python/pyspark/sql/dataframe.py:170: error: Unused "type: ignore" comment
+ python/pyspark/sql/dataframe.py:181: error: Unused "type: ignore" comment
+ python/pyspark/sql/dataframe.py:187: error: Unused "type: ignore" comment
+ python/pyspark/sql/streaming/query.py:46: error: Unused "type: ignore" comment
+ python/pyspark/sql/streaming/query.py:57: error: Unused "type: ignore" comment
+ python/pyspark/sql/streaming/query.py:65: error: Unused "type: ignore" comment
+ python/pyspark/sql/streaming/query.py:75: error: Unused "type: ignore" comment
+ python/pyspark/sql/streaming/query.py:101: error: Unused "type: ignore" comment
+ python/pyspark/sql/streaming/query.py:109: error: Unused "type: ignore" comment
+ python/pyspark/mllib/linalg/__init__.py:1620: error: Unused "type: ignore" comment
+ python/pyspark/mllib/linalg/__init__.py:1629: error: Unused "type: ignore" comment
+ python/pyspark/ml/util.py:646: error: Unused "type: ignore" comment
+ python/pyspark/ml/util.py:655: error: Unused "type: ignore" comment
+ python/pyspark/mllib/regression.py:120: error: Unused "type: ignore" comment
+ python/pyspark/mllib/regression.py:126: error: Unused "type: ignore" comment
+ python/pyspark/mllib/classification.py:76: error: Unused "type: ignore" comment
+ python/pyspark/mllib/classification.py:217: error: Unused "type: ignore" comment
+ python/pyspark/mllib/classification.py:225: error: Unused "type: ignore" comment
+ python/pyspark/ml/base.py:399: error: Unused "type: ignore" comment
+ python/pyspark/ml/wrapper.py:448: error: Unused "type: ignore" comment
+ python/pyspark/ml/tree.py:49: error: Unused "type: ignore" comment
+ python/pyspark/ml/tree.py:55: error: Unused "type: ignore" comment
+ python/pyspark/ml/tree.py:61: error: Unused "type: ignore" comment
+ python/pyspark/ml/tree.py:221: error: Unused "type: ignore" comment
+ python/pyspark/ml/tree.py:227: error: Unused "type: ignore" comment
+ python/pyspark/ml/tree.py:233: error: Unused "type: ignore" comment
+ python/pyspark/ml/tree.py:239: error: Unused "type: ignore" comment
+ python/pyspark/ml/tree.py:245: error: Unused "type: ignore" comment
+ python/pyspark/ml/recommendation.py:612: error: Unused "type: ignore" comment
+ python/pyspark/ml/recommendation.py:618: error: Unused "type: ignore" comment
+ python/pyspark/ml/recommendation.py:627: error: Unused "type: ignore" comment
+ python/pyspark/ml/fpm.py:127: error: Unused "type: ignore" comment
+ python/pyspark/ml/fpm.py:137: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:1222: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:1892: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:1900: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:1908: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:2258: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:2473: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:2823: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:2831: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:3332: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:4010: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:4018: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:4462: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:4470: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:4835: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:4846: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:5630: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:5638: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:6266: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:6275: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:6732: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:7147: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:7422: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:456: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:464: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:472: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:480: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:520: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:528: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:537: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:546: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:555: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:574: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:590: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:606: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:621: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:638: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:654: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:662: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:670: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:678: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:980: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:988: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:997: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:1603: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:1992: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:2311: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:2319: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:2327: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:2737: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:2745: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:2753: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:2795: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:2803: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:2812: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:2820: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:2828: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:2836: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:2844: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:2866: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:2874: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:2882: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:2893: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:2910: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:2918: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:2926: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:2937: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:2948: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:3283: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:3291: error: Unused "type: ignore" comment
+ python/pyspark/ml/regression.py:3299: error: Unused "type: ignore" comment
+ python/pyspark/ml/clustering.py:86: error: Unused "type: ignore" comment
+ python/pyspark/ml/clustering.py:94: error: Unused "type: ignore" comment
+ python/pyspark/ml/clustering.py:102: error: Unused "type: ignore" comment
+ python/pyspark/ml/clustering.py:110: error: Unused "type: ignore" comment
+ python/pyspark/ml/clustering.py:118: error: Unused "type: ignore" comment
+ python/pyspark/ml/clustering.py:126: error: Unused "type: ignore" comment
+ python/pyspark/ml/clustering.py:134: error: Unused "type: ignore" comment
+ python/pyspark/ml/clustering.py:213: error: Unused "type: ignore" comment
+ python/pyspark/ml/clustering.py:223: error: Unused "type: ignore" comment
+ python/pyspark/ml/clustering.py:239: error: Unused "type: ignore" comment
+ python/pyspark/ml/clustering.py:249: error: Unused "type: ignore" comment
+ python/pyspark/ml/clustering.py:532: error: Unused "type: ignore" comment
+ python/pyspark/ml/clustering.py:540: error: Unused "type: ignore" comment
+ python/pyspark/ml/clustering.py:548: error: Unused "type: ignore" comment
+ python/pyspark/ml/clustering.py:564: error: Unused "type: ignore" comment
+ python/pyspark/ml/clustering.py:686: error: Unused "type: ignore" comment
+ python/pyspark/ml/clustering.py:1024: error: Unused "type: ignore" comment
+ python/pyspark/ml/clustering.py:1248: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:183: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:287: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:338: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:346: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:354: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:363: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:389: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:397: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:405: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:413: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:428: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:438: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:447: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:455: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:464: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:488: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:498: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:515: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:539: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:548: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:558: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:567: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:577: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:860: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:868: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:1530: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:1539: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:1548: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:1556: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:1564: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:1612: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:1621: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:2282: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:2288: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:2770: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:3021: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:3029: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:3037: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:3313: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:4229: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:4237: error: Unused "type: ignore" comment
+ python/pyspark/ml/classification.py:4245: error: Unused "type: ignore" comment
+ python/pyspark/mllib/recommendation.py:211: error: Unused "type: ignore" comment
+ python/pyspark/mllib/feature.py:254: error: Unused "type: ignore" comment
+ python/pyspark/mllib/feature.py:262: error: Unused "type: ignore" comment
+ python/pyspark/mllib/feature.py:270: error: Unused "type: ignore" comment
+ python/pyspark/mllib/feature.py:278: error: Unused "type: ignore" comment
+ python/pyspark/mllib/evaluation.py:88: error: Unused "type: ignore" comment
+ python/pyspark/mllib/evaluation.py:97: error: Unused "type: ignore" comment
+ python/pyspark/mllib/evaluation.py:164: error: Unused "type: ignore" comment
+ python/pyspark/mllib/evaluation.py:173: error: Unused "type: ignore" comment
+ python/pyspark/mllib/evaluation.py:182: error: Unused "type: ignore" comment
+ python/pyspark/mllib/evaluation.py:191: error: Unused "type: ignore" comment
+ python/pyspark/mllib/evaluation.py:200: error: Unused "type: ignore" comment
+ python/pyspark/mllib/evaluation.py:351: error: Unused "type: ignore" comment
+ python/pyspark/mllib/evaluation.py:360: error: Unused "type: ignore" comment
+ python/pyspark/mllib/evaluation.py:369: error: Unused "type: ignore" comment
+ python/pyspark/mllib/evaluation.py:377: error: Unused "type: ignore" comment
+ python/pyspark/mllib/evaluation.py:386: error: Unused "type: ignore" comment
+ python/pyspark/mllib/evaluation.py:485: error: Unused "type: ignore" comment
+ python/pyspark/mllib/evaluation.py:617: error: Unused "type: ignore" comment
+ python/pyspark/mllib/evaluation.py:626: error: Unused "type: ignore" comment
+ python/pyspark/mllib/evaluation.py:635: error: Unused "type: ignore" comment
+ python/pyspark/mllib/evaluation.py:644: error: Unused "type: ignore" comment
+ python/pyspark/mllib/evaluation.py:652: error: Unused "type: ignore" comment
+ python/pyspark/mllib/evaluation.py:661: error: Unused "type: ignore" comment
+ python/pyspark/mllib/linalg/distributed.py:503: error: Unused "type: ignore" comment
+ python/pyspark/mllib/linalg/distributed.py:520: error: Unused "type: ignore" comment
+ python/pyspark/mllib/linalg/distributed.py:528: error: Unused "type: ignore" comment
+ python/pyspark/mllib/clustering.py:82: error: Unused "type: ignore" comment
+ python/pyspark/mllib/clustering.py:89: error: Unused "type: ignore" comment
+ python/pyspark/mllib/clustering.py:284: error: Unused "type: ignore" comment
+ python/pyspark/mllib/clustering.py:290: error: Unused "type: ignore" comment
+ python/pyspark/mllib/clustering.py:535: error: Unused "type: ignore" comment
+ python/pyspark/mllib/clustering.py:544: error: Unused "type: ignore" comment
+ python/pyspark/mllib/clustering.py:555: error: Unused "type: ignore" comment
+ python/pyspark/mllib/clustering.py:779: error: Unused "type: ignore" comment
+ python/pyspark/mllib/clustering.py:947: error: Unused "type: ignore" comment

artigraph (https://github.com/artigraph/artigraph)
+ src/arti/graphs/__init__.py:227: error: Unused "type: ignore" comment
+ src/arti/graphs/__init__.py:246: error: Unused "type: ignore" comment
+ src/arti/graphs/__init__.py:251: error: Unused "type: ignore" comment

core (https://github.com/home-assistant/core)
+ homeassistant/components/norway_air/air_quality.py:109: error: Unused "type: ignore" comment
+ homeassistant/components/norway_air/air_quality.py:115: error: Unused "type: ignore" comment
+ homeassistant/components/norway_air/air_quality.py:121: error: Unused "type: ignore" comment
+ homeassistant/components/norway_air/air_quality.py:127: error: Unused "type: ignore" comment
+ homeassistant/components/norway_air/air_quality.py:133: error: Unused "type: ignore" comment
+ homeassistant/components/izone/climate.py:311: error: Unused "type: ignore" comment
+ homeassistant/components/izone/climate.py:319: error: Unused "type: ignore" comment
+ homeassistant/components/izone/climate.py:325: error: Unused "type: ignore" comment
+ homeassistant/components/izone/climate.py:333: error: Unused "type: ignore" comment
+ homeassistant/components/izone/climate.py:363: error: Unused "type: ignore" comment
+ homeassistant/components/izone/climate.py:391: error: Unused "type: ignore" comment
+ homeassistant/components/izone/climate.py:397: error: Unused "type: ignore" comment
+ homeassistant/components/izone/climate.py:536: error: Unused "type: ignore" comment
+ homeassistant/components/plex/media_player.py:251: error: Unused "type: ignore" comment
+ homeassistant/components/plex/media_player.py:282: error: Unused "type: ignore" comment
+ homeassistant/components/plex/media_player.py:288: error: Unused "type: ignore" comment
+ homeassistant/components/plex/media_player.py:294: error: Unused "type: ignore" comment
+ homeassistant/components/plex/media_player.py:300: error: Unused "type: ignore" comment
+ homeassistant/components/plex/media_player.py:306: error: Unused "type: ignore" comment
+ homeassistant/components/plex/media_player.py:312: error: Unused "type: ignore" comment
+ homeassistant/components/plex/media_player.py:318: error: Unused "type: ignore" comment
+ homeassistant/components/plex/media_player.py:324: error: Unused "type: ignore" comment
+ homeassistant/components/plex/media_player.py:330: error: Unused "type: ignore" comment
+ homeassistant/components/plex/media_player.py:336: error: Unused "type: ignore" comment
+ homeassistant/components/plex/media_player.py:342: error: Unused "type: ignore" comment
+ homeassistant/components/plex/media_player.py:348: error: Unused "type: ignore" comment
+ homeassistant/components/plex/media_player.py:354: error: Unused "type: ignore" comment
+ homeassistant/components/plex/media_player.py:360: error: Unused "type: ignore" comment
+ homeassistant/components/plex/media_player.py:366: error: Unused "type: ignore" comment
+ homeassistant/components/plex/media_player.py:372: error: Unused "type: ignore" comment
+ homeassistant/components/plex/media_player.py:378: error: Unused "type: ignore" comment
+ homeassistant/components/plex/media_player.py:384: error: Unused "type: ignore" comment

pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/indexes/base.py:5094: error: Unused "type: ignore" comment
+ pandas/core/arrays/interval.py:1506: error: Unused "type: ignore" comment
+ pandas/core/indexes/numeric.py:217: error: Unused "type: ignore" comment
+ pandas/core/indexes/period.py:196: error: Unused "type: ignore" comment
+ pandas/core/indexes/period.py:203: error: Unused "type: ignore" comment
+ pandas/core/indexes/period.py:210: error: Unused "type: ignore" comment

@ilevkivskyi
Copy link
Member Author

mypy_primer looks great, also I think this is a low-risk PR, so I will go ahead and just merge it.

@ilevkivskyi ilevkivskyi merged commit b805551 into python:master Aug 14, 2022
@ilevkivskyi ilevkivskyi deleted the allow-decorated-property branch August 14, 2022 00:00
@graingert
Copy link
Contributor

graingert commented Aug 14, 2022

It wasn't actually my idea, I got like 10% of the way in before seeing @sobolevn tried first #11719

@yashk2810
Copy link

When will mypy release so that we can use this fix?

@ilevkivskyi
Copy link
Member Author

I am not sure, if it will be included in 0.980, then in few days, otherwise it will be in 0.990 around end of September.

bmario added a commit to metricq/aiocouch that referenced this pull request Dec 2, 2022
Properties are somewhat supported now:
python/mypy#13409
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Decorated property not supported
3 participants