Code Monkey home page Code Monkey logo

motor-types's People

Contributors

armanddidierjean avatar doekeb avatar haoyun avatar jecluis avatar l0rd-zer0 avatar lmichaelis avatar tbekolay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

motor-types's Issues

Generics on document type

Thanks again for the stubs!

There is a slight fundamental difference between typing in pymongo and this package. Namely, many pymongo classes are generic on the document type. See pymongo.MongoClient as the main example. The client is created with the document_class keyword argument which defaults to dict. This allows methods like Collection.find_one to be very specific about their return type (e.g. if the collection belongs to a client where the document class is dict, then the return type of Collection.find_one is dict[str, Any]).

Currently, this package is set up to always return _Document = typing.Mapping[str, typing.Any] (https://github.com/L0RD-ZER0/Motor-Types/blob/8ffaa4fb9c0e9e93ef0425ea761b47d0502b1d87/motor-stubs/core.pyi#L31C1-L31C44). While this behavior is not incorrect per se, it does present a major development experience difference between the two packages (and after all, motor is built to very closely mirror pymongo).

For what it's worth, I never use anything other than dict as the document class in either package and I find the constant need for defining everything to be generic on the document class to be quite cumbersome. Nevertheless, I thought I would create this issue to hopefully spark a discussion around the topic ๐Ÿ˜„

Add incomplete mapping to Tornado stubs instead of empty file

Hello,
due to the actual tornado stub being empty, the reference file when using elements like MotorClient and MotorDatabase is to default to not resolving the import.
image

MyPy will complain, as the language server.

Substituting it with a basic stub does not enforce correct typing, but does not block the issue
This is generated via stubgen, of course this is not a real stub but at least solves the issue temporarily, until a full stub is implemented

image

Incomplete is better than an empty file, but might hide the fact that this is not implemented, I'm not sure if this was a deliberate implementation decision.

motor_tornado.pyi

from _typeshed import Incomplete
from typing import TypeVar

T = TypeVar('T')
MotorClient: Incomplete
MotorDatabase: Incomplete
MotorCollection: Incomplete
MotorCursor: Incomplete
MotorCommandCursor: Incomplete
MotorChangeStream: Incomplete
MotorGridFSBucket: Incomplete
MotorGridIn: Incomplete
MotorGridOut: Incomplete
MotorGridOutCursor: Incomplete
MotorClientEncryption: Incomplete

`keys` in `create_index()`

async def create_index(
self,
keys: _Key_or_Index,
session: typing.Optional[_Session] = None,
comment: typing.Optional[typing.Any] = None,
**kwargs: typing.Any,
) -> str: ...

The example in the documentation

my_collection.create_index([("mike", pymongo.DESCENDING),
                            "eliot"])

is an exception.

keys can be a list of Union[tuple, str] instead of only a list of Union[Tuple] (_Index).

[BUG] Error in the variable name

Thanks for the stubs!

Error in the variable name. You need to use max_commit_time_ms instead of max_commit_time_ns

In stubs

    def start_transaction(
        self,
        read_concern: typing.Optional[pymongo.read_concern.ReadConcern] = None,
        write_concern: typing.Optional[pymongo.write_concern.WriteConcern] = None,
        read_preference: typing.Optional[_ReadPreferences] = None,
        max_commit_time_ns: typing.Optional[int] = None,
    ) -> _MotorTransactionContext: ...

In motor

    def start_transaction(
        self, read_concern=None, write_concern=None, read_preference=None, max_commit_time_ms=None
    ):

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.