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

Revert "fix: vim.eval('v:true') should return python bool #506" #562

Merged
merged 3 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ Pynvim defines some extensions over the vim python API:

See the [Python Plugin API](http://pynvim.readthedocs.io/en/latest/usage/python-plugin-api.html) documentation for usage of this new functionality.

### Known Issues
- Vim evaluates `'v:<bool>'` to `<class 'bool'>`, whereas neovim evaluates to `<class 'str'>`. This is expected behaviour due to the way booleans are implemented in python as explained [here](https://github.com/neovim/pynvim/issues/523#issuecomment-1495502011).

Development
-----------

Expand Down
2 changes: 1 addition & 1 deletion pynvim/plugin/script_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def writelines(self, seq):


def num_to_str(obj):
if isinstance(obj, num_types) and not isinstance(obj, bool):
if isinstance(obj, num_types):
return str(obj)
else:
return obj
Expand Down
11 changes: 0 additions & 11 deletions test/test_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,3 @@ def test_host_async_error(vim):
assert event[1] == 'nvim_error_event'
assert 'rplugin-host: Async request caused an error:\nboom\n' \
in h._on_error_event(None, 'boom')


def test_legacy_vim_eval(vim):
h = ScriptHost(vim)
try:
assert h.legacy_vim.eval('1') == '1'
assert h.legacy_vim.eval('v:null') is None
assert h.legacy_vim.eval('v:true') is True
assert h.legacy_vim.eval('v:false') is False
Copy link
Member

Choose a reason for hiding this comment

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

Aren't these tests still useful? Could change the expected values.

finally:
h.teardown()
Loading