Skip to content
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

Replaced argument 'async' with 'async_' #103 #104

Merged
merged 1 commit into from
Oct 23, 2019
Merged

Conversation

donalm
Copy link

@donalm donalm commented Sep 22, 2018

I don't think that the _connect method that's getting called here needs to accept both async= and async_= keyword arguments, so there's an opportunity to avoid the creation of a dict. We can just pass a bool into the _connect method directly.

Note that _connect is already careful to not pass on an async_ argument unless async_'s value is True:

def _connect(dsn, connection_factory=None, async_=False):                       
    if connection_factory is None:                                              
        connection_factory = Connection                                         
                                                                                
    # Mimic the construction method as used by psycopg2, which notes:           
    # Here we are breaking the connection.__init__ interface defined            
    # by psycopg2. So, if not requiring an async conn, avoid passing            
    # the async_ parameter.                                                     
    if async_:                                                                  
        return connection_factory(dsn, async_=True)                             
    else:                                                                       
        return connection_factory(dsn)

Copy link
Member

@lopuhin lopuhin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, as _connect has False as default value for async_, well spotted! The build failure on python 2.6 looks unrelated. Just to be sure, this is a cleanup and does not change outside behaviour, right?

@lopuhin
Copy link
Member

lopuhin commented Sep 24, 2018

Oh sorry never mind, I see that this is a fix for #103 now

@thedrow
Copy link

thedrow commented Oct 23, 2019

@lopuhin Can we merge this?

@lopuhin lopuhin merged commit 0c43c6e into chtd:master Oct 23, 2019
@lopuhin
Copy link
Member

lopuhin commented Oct 23, 2019

Merged, thanks @donalm and @thedrow

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.

3 participants