Skip to content

Commit 8bb7964

Browse files
authored
Merge #469 from jamessan/github-actions
2 parents b79717f + e4224fc commit 8bb7964

File tree

14 files changed

+63
-74
lines changed

14 files changed

+63
-74
lines changed

.github/workflows/test.yml

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: test
1+
name: ci
22
on:
33
push:
44
pull_request:
@@ -13,6 +13,21 @@ env:
1313
PYTEST_ADDOPTS: '-vv'
1414

1515
jobs:
16+
lint:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
- uses: actions/setup-python@v4
21+
with:
22+
cache: 'pip'
23+
python-version: 3.11
24+
- name: install dependencies
25+
run: pip install tox tox-gh-actions
26+
- name: checkqa
27+
env:
28+
TOXENV: 'checkqa,docs'
29+
run: tox
30+
1631
test:
1732
strategy:
1833
fail-fast: false
@@ -34,8 +49,6 @@ jobs:
3449
EXTRACT: unzip
3550

3651
runs-on: ${{ matrix.os }}
37-
38-
# Steps represent a sequence of tasks that will be executed as part of the job
3952
steps:
4053
- uses: actions/checkout@v3
4154
- uses: actions/setup-python@v4
@@ -58,34 +71,11 @@ jobs:
5871
run: echo "$(pwd)/${{ matrix.NVIM_BIN_PATH }}" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
5972

6073
- name: install dependencies
61-
run: |
62-
pip install . # Install from setup.py
63-
pip install -q pytest
74+
run: pip install tox tox-gh-actions
6475

6576
- name: test
6677
run: |
6778
echo $PATH
6879
which nvim
6980
nvim --version
70-
python -m pytest
71-
72-
- uses: codecov/codecov-action@v3
73-
if: runner.os == 'macOS'
74-
with:
75-
verbose: true # optional (default = false)
76-
77-
# TODO: tox, codecov steps from old travis workflow
78-
#
79-
# env: CI_TARGET=checkqa TOXENV=checkqa,docs
80-
# script:
81-
# - tox
82-
# after_script:
83-
# - if [ $CI_TARGET = tests ]; then
84-
# set -x;
85-
# pip install coverage;
86-
# coverage combine;
87-
# coverage report -m;
88-
# coverage xml;
89-
# bash <(curl --retry 5 --silent --fail https://codecov.io/bash) -f coverage.xml;
90-
# set +x;
91-
# fi
81+
tox

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
#
6969
# This is also used if you do content translation via gettext catalogs.
7070
# Usually you set "language" from the command line for these cases.
71-
language = None
71+
language = 'en'
7272

7373
# List of patterns, relative to source directory, that match files and
7474
# directories to ignore when looking for source files.

pynvim/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import os
77
import sys
88
from types import SimpleNamespace as Version
9-
from typing import List, cast, overload
9+
from typing import List, Optional, cast, overload
1010

1111
from pynvim.api import Nvim, NvimError
1212
from pynvim.msgpack_rpc import (ErrorResponse, Session, TTransportType, child_session,
@@ -28,7 +28,7 @@
2828
'ErrorResponse')
2929

3030

31-
def start_host(session: Session = None) -> None:
31+
def start_host(session: Optional[Session] = None) -> None:
3232
"""Promote the current process into python plugin host for Nvim.
3333
3434
Start msgpack-rpc event loop for `session`, listening for Nvim requests
@@ -101,10 +101,10 @@ def attach(session_type: Literal['stdio']) -> Nvim: ...
101101

102102
def attach(
103103
session_type: TTransportType,
104-
address: str = None,
104+
address: Optional[str] = None,
105105
port: int = 7450,
106-
path: str = None,
107-
argv: List[str] = None,
106+
path: Optional[str] = None,
107+
argv: Optional[List[str]] = None,
108108
decode: Literal[True] = True
109109
) -> Nvim:
110110
"""Provide a nicer interface to create python api sessions.

pynvim/api/buffer.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
@overload
16-
def adjust_index(idx: int, default: int = None) -> int:
16+
def adjust_index(idx: int, default: Optional[int] = None) -> int:
1717
...
1818

1919

@@ -23,11 +23,11 @@ def adjust_index(idx: Optional[int], default: int) -> int:
2323

2424

2525
@overload
26-
def adjust_index(idx: Optional[int], default: int = None) -> Optional[int]:
26+
def adjust_index(idx: Optional[int], default: Optional[int] = None) -> Optional[int]:
2727
...
2828

2929

30-
def adjust_index(idx: Optional[int], default: int = None) -> Optional[int]:
30+
def adjust_index(idx: Optional[int], default: Optional[int] = None) -> Optional[int]:
3131
"""Convert from python indexing convention to nvim indexing convention."""
3232
if idx is None:
3333
return default
@@ -161,7 +161,7 @@ def add_highlight(
161161
col_start: int = 0,
162162
col_end: int = -1,
163163
src_id: int = -1,
164-
async_: bool = None,
164+
async_: Optional[bool] = None,
165165
**kwargs: Any
166166
) -> int:
167167
"""Add a highlight to the buffer."""
@@ -181,7 +181,7 @@ def clear_highlight(
181181
src_id: int,
182182
line_start: int = 0,
183183
line_end: int = -1,
184-
async_: bool = None,
184+
async_: Optional[bool] = None,
185185
**kwargs: Any
186186
) -> None:
187187
"""Clear highlights from the buffer."""
@@ -301,7 +301,7 @@ def __iter__(self) -> Iterator[str]:
301301
yield self._buffer[i]
302302

303303
def append(
304-
self, lines: Union[str, bytes, List[Union[str, bytes]]], i: int = None
304+
self, lines: Union[str, bytes, List[Union[str, bytes]]], i: Optional[int] = None
305305
) -> None:
306306
i = self._normalize_index(i)
307307
if i is None:

pynvim/api/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ def __init__(
123123
self,
124124
obj: IRemote,
125125
get_method: str,
126-
set_method: str = None,
127-
del_method: str = None
126+
set_method: Optional[str] = None,
127+
del_method: Optional[str] = None
128128
):
129129
"""Initialize a RemoteMap with session, getter/setter."""
130130
self._get = functools.partial(obj.request, get_method)

pynvim/api/nvim.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def __init__(
112112
metadata: Dict[str, Any],
113113
types: Dict[int, Any],
114114
decode: TDecodeMode = True,
115-
err_cb: Callable[[str], None] = None
115+
err_cb: Optional[Callable[[str], None]] = None
116116
):
117117
"""Initialize a new Nvim instance. This method is module-private."""
118118
self._session = session
@@ -142,7 +142,7 @@ def __init__(
142142
self._err_cb = err_cb
143143
self.loop = self._session.loop._loop
144144

145-
def _from_nvim(self, obj: Any, decode: TDecodeMode = None) -> Any:
145+
def _from_nvim(self, obj: Any, decode: Optional[TDecodeMode] = None) -> Any:
146146
if decode is None:
147147
decode = self._decode
148148
if type(obj) is ExtType:
@@ -213,8 +213,8 @@ def run_loop(
213213
self,
214214
request_cb: Optional[Callable[[str, List[Any]], Any]],
215215
notification_cb: Optional[Callable[[str, List[Any]], Any]],
216-
setup_cb: Callable[[], None] = None,
217-
err_cb: Callable[[str], Any] = None
216+
setup_cb: Optional[Callable[[], None]] = None,
217+
err_cb: Optional[Callable[[str], Any]] = None
218218
) -> None:
219219
"""Run the event loop to receive requests and notifications from Nvim.
220220
@@ -275,7 +275,7 @@ def with_decode(self, decode: Literal[True] = True) -> 'Nvim':
275275
self.metadata, self.types, decode, self._err_cb)
276276

277277
def ui_attach(
278-
self, width: int, height: int, rgb: bool = None, **kwargs: Any
278+
self, width: int, height: int, rgb: Optional[bool] = None, **kwargs: Any
279279
) -> None:
280280
"""Register as a remote UI.
281281
@@ -375,14 +375,7 @@ def chdir(self, dir_path: str) -> None:
375375
return self.request('nvim_set_current_dir', dir_path)
376376

377377
def feedkeys(self, keys: str, options: str = '', escape_csi: bool = True) -> None:
378-
"""Push `keys` to Nvim user input buffer.
379-
380-
Options can be a string with the following character flags:
381-
- 'm': Remap keys. This is default.
382-
- 'n': Do not remap keys.
383-
- 't': Handle keys as if typed; otherwise they are handled as if coming
384-
from a mapping. This matters for undo, opening folds, etc.
385-
"""
378+
"""Push `keys` to Nvim user input buffer."""
386379
return self.request('nvim_feedkeys', keys, options, escape_csi)
387380

388381
def input(self, bytes: AnyStr) -> int:

pynvim/compat.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def find_module(fullname, path): # type: ignore
2121
else:
2222
newpath.append(element)
2323
path = newpath
24+
from imp import find_module as original_find_module
2425
return original_find_module(fullname, path)
2526

2627

pynvim/msgpack_rpc/event_loop/asyncio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
loop_cls = asyncio.SelectorEventLoop
2525
if os.name == 'nt':
26-
from asyncio.windows_utils import PipeHandle
26+
from asyncio.windows_utils import PipeHandle # type: ignore[attr-defined]
2727
import msvcrt
2828

2929
# On windows use ProactorEventLoop which support pipes and is backed by the
@@ -114,7 +114,7 @@ def _connect_stdio(self) -> None:
114114
)
115115
else:
116116
pipe = os.fdopen(rename_stdout, 'wb')
117-
coroutine = self._loop.connect_write_pipe(self._fact, pipe)
117+
coroutine = self._loop.connect_write_pipe(self._fact, pipe) # type: ignore[assignment]
118118
self._loop.run_until_complete(coroutine)
119119
debug("native stdout connection successful")
120120

pynvim/msgpack_rpc/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def request(self, method: AnyStr, *args: Any, **kwargs: Any) -> Any:
140140
def run(self,
141141
request_cb: Callable[[str, List[Any]], None],
142142
notification_cb: Callable[[str, List[Any]], None],
143-
setup_cb: Callable[[], None] = None) -> None:
143+
setup_cb: Optional[Callable[[], None]] = None) -> None:
144144
"""Run the event loop to receive requests and notifications from Nvim.
145145
146146
Like `AsyncSession.run()`, but `request_cb` and `notification_cb` are

pynvim/plugin/decorators.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import inspect
44
import logging
55
import sys
6-
from typing import Any, Callable, Dict, TypeVar, Union
6+
from typing import Any, Callable, Dict, Optional, TypeVar, Union
77

88
from pynvim.compat import unicode_errors_default
99

@@ -52,14 +52,14 @@ def dec(f: F) -> F:
5252
def command(
5353
name: str,
5454
nargs: Union[str, int] = 0,
55-
complete: str = None,
56-
range: Union[str, int] = None,
57-
count: int = None,
55+
complete: Optional[str] = None,
56+
range: Optional[Union[str, int]] = None,
57+
count: Optional[int] = None,
5858
bang: bool = False,
5959
register: bool = False,
6060
sync: bool = False,
6161
allow_nested: bool = False,
62-
eval: str = None
62+
eval: Optional[str] = None
6363
) -> Callable[[F], F]:
6464
"""Tag a function or plugin method as a Nvim command handler."""
6565
def dec(f: F) -> F:
@@ -112,7 +112,7 @@ def autocmd(
112112
pattern: str = '*',
113113
sync: bool = False,
114114
allow_nested: bool = False,
115-
eval: str = None
115+
eval: Optional[str] = None
116116
) -> Callable[[F], F]:
117117
"""Tag a function or plugin method as a Nvim autocommand handler."""
118118
def dec(f: F) -> F:
@@ -150,7 +150,7 @@ def function(
150150
range: Union[bool, str, int] = False,
151151
sync: bool = False,
152152
allow_nested: bool = False,
153-
eval: str = None
153+
eval: Optional[str] = None
154154
) -> Callable[[F], F]:
155155
"""Tag a function or plugin method as a Nvim function handler."""
156156
def dec(f: F) -> F:

0 commit comments

Comments
 (0)