Title: Declare peewee query operators as methods by klen · Pull Request #16865 · python/typeshed · GitHub
Open Graph Title: Declare peewee query operators as methods by klen · Pull Request #16865 · python/typeshed
X Title: Declare peewee query operators as methods by klen · Pull Request #16865 · python/typeshed
Description: ColumnBase and _HashableSource declare their comparison and bitwise operators as ClassVar[Callable[[Self, Any], Expression]]: __and__: ClassVar[Callable[[Self, Any], Expression]] __or__: ClassVar[Callable[[Self, Any], Expression]] __gt__: ClassVar[Callable[[Self, Any], Expression]] regexp: ClassVar[Callable[[Self, Any], Expression]] Some type checkers do not treat such annotated attributes as operators. Two code samples from a real project (peewee 3.19, peewee_aio models): # pyrefly: `&` is not supported between `Expression` and `Expression` Event.state.is_null(is_null=False) & (Event.updated > dtfrom) # pyrefly: Expected 1 more positional argument — `Self` in `Callable` is not bound Location.name.concat(" ").regexp(pattern) At runtime these are ordinary methods generated by ColumnBase._e(...), i.e. def inner(self, rhs), and the neighbouring __add__ / __radd__ / __eq__ / __ne__ members are already declared as methods in this stub. Declaring the remaining operators the same way keeps mypy and pyright behaviour unchanged (Expression is still returned) and makes the operators visible to the other checkers. Also converted the method-like entries (like, ilike, bin_and, bin_or, in_, not_in, regexp, iregexp) and the comparison operators of _HashableSource, which have the same problem. Verification: with this stub installed, mypy --strict on a ~870-module project that uses peewee/peewee_aio stays clean and its test-suite passes; flake8-pyi is clean on the file.
Open Graph Description: ColumnBase and _HashableSource declare their comparison and bitwise operators as ClassVar[Callable[[Self, Any], Expression]]: __and__: ClassVar[Callable[[Self, Any], Expression]] __or__: ClassVar[C...
X Description: ColumnBase and _HashableSource declare their comparison and bitwise operators as ClassVar[Callable[[Self, Any], Expression]]: __and__: ClassVar[Callable[[Self, Any], Expression]] __or__: ClassVar[C...
Opengraph URL: https://github.com/python/typeshed/pull/16865
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:875acda6-a041-451d-5188-33ee79b5281d |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8EC2:302FC:51C44D:6D6377:6B002FC2 |
| html-safe-nonce | 6575b6563b72c3ea2d02419f8d6d1770da0159c259eccf98f3829f6a86576c46 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RUMyOjMwMkZDOjUxQzQ0RDo2RDYzNzc6NkIwMDJGQzIiLCJ2aXNpdG9yX2lkIjoiODYyMTU5NjUzMDA2MDU3MDU2MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ffe89c252b98c390608cb79974c7989c1744ac5fd3ecbc6e14f928bfc397556d |
| hovercard-subject-tag | pull_request:5386626088 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/typeshed/pull/16865/files |
| twitter:image | https://avatars.githubusercontent.com/u/90699?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/90699?s=400&v=4 |
| og:image:alt | ColumnBase and _HashableSource declare their comparison and bitwise operators as ClassVar[Callable[[Self, Any], Expression]]: __and__: ClassVar[Callable[[Self, Any], Expression]] __or__: ClassVar[C... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/python/typeshed git https://github.com/python/typeshed.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 31696383 |
| octolytics-dimension-repository_nwo | python/typeshed |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31696383 |
| octolytics-dimension-repository_network_root_nwo | python/typeshed |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width