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

Change the data type of a Buffer so that it works correctly #471

Closed
wants to merge 1 commit into from

Conversation

farisachugthai
Copy link
Contributor

from pynvim.api.buffer import *

Doesn't correctly import Buffer. __all__ is incorrectly defined as a tuple and as a result it tries importing each individual letter instead of the actual class.

In addition, the python reference explicitly defines that __all__ should be a list.

@@ -3,7 +3,7 @@
from pynvim.compat import IS_PYTHON3, check_async


__all__ = ('Buffer')
__all__ = ['Buffer']
Copy link
Member

Choose a reason for hiding this comment

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

Alternatively, make it an actual tuple by adding the missing comma:

Suggested change
__all__ = ['Buffer']
__all__ = ('Buffer',)

Looks like this is needed in pynvim/api/{nvim,tabpage,window}.py, pynvim/msgpack_rpc/event_loop/init.py, and pynvim/plugin/host.py.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This does technically work however according to the reference guide the data type of __all__ is explicitly supposed to be a list

Copy link
Contributor

Choose a reason for hiding this comment

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

@farisachugthai
Ok. A link/ref would have been useful, but I believe you.. :)

Can you update the other places also, please?

Looks like this is needed in pynvim/api/{nvim,tabpage,window}.py, pynvim/msgpack_rpc/event_loop/init.py, and pynvim/plugin/host.py.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Couldn't find it in the ref again but some googling got me this from the tutorial.

https://docs.python.org/3/tutorial/modules.html#importing-from-a-package

The import statement uses the following convention: if a package’s __init__.py code defines a list named __all__, it is taken to be the list of module names that should be imported when from package import * is encountered. It is up to the package author to keep this list up-to-date when a new version of the package is released.

Yeah sure I can do that. Is it okay if we merge this and I do the rest in a separate PR?

@wookayin
Copy link
Member

This already has been fixed by #492 (ac03f5c), and released as a part of pynvim 0.5.

@wookayin wookayin closed this Dec 26, 2023
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.

4 participants