Skip to content

Commit 9f7df02

Browse files
authored
feat!: drop support for Python <= 3.9 #610
Also try supporting 3.14
1 parent 99ae59f commit 9f7df02

13 files changed

Lines changed: 17 additions & 113 deletions

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,12 @@ jobs:
2929
matrix:
3030
config: [
3131
# NOTE: don't forget updating tox.ini
32+
{ python-version: '3.14', neovim-version: 'nightly' },
3233
{ python-version: '3.13', neovim-version: 'nightly' },
3334
{ python-version: '3.12', neovim-version: 'nightly' },
3435
{ python-version: '3.12', neovim-version: 'stable' },
3536
{ python-version: '3.11' },
3637
{ python-version: '3.10' },
37-
# for python 3.7~3.9, use older version of OS (ubuntu-20.04 and macos-13)
38-
{ python-version: '3.9', ubuntu: '20.04', macos: '13' },
39-
{ python-version: '3.8', ubuntu: '20.04', macos: '13' },
40-
{ python-version: '3.7', ubuntu: '20.04', macos: '13' },
4138
]
4239
os: ['ubuntu', 'macos', 'windows']
4340

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ connecting to and scripting Nvim processes through its msgpack-rpc API.
1010
Install
1111
-------
1212

13-
Supports python 3.7 or later.
13+
Supports python 3.10 or later.
1414

1515
- Installation option #1: install using uv (recommended):
1616

pynvim/__init__.py

Lines changed: 1 addition & 6 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, Optional, cast, overload
9+
from typing import List, Literal, Optional, cast, overload
1010

1111
from pynvim._version import VERSION, __version__
1212
from pynvim.api import Nvim, NvimError
@@ -16,11 +16,6 @@
1616
from pynvim.plugin import (Host, autocmd, command, decode, encoding, function,
1717
plugin, rpc_export, shutdown_hook)
1818

19-
if sys.version_info < (3, 8):
20-
from typing_extensions import Literal
21-
else:
22-
from typing import Literal
23-
2419

2520
__all__ = ('tcp_session', 'socket_session', 'stdio_session', 'child_session',
2621
'start_host', 'autocmd', 'command', 'encoding', 'decode',

pynvim/api/common.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
"""Code shared between the API classes."""
22
import functools
3-
import sys
43
from abc import ABC, abstractmethod
5-
from typing import (Any, Callable, Generic, Iterator, List, Optional, Tuple, TypeVar,
6-
Union, overload)
4+
from typing import (Any, Callable, Generic, Iterator, List, Literal, Optional, Protocol,
5+
Tuple, TypeVar, Union, overload)
76

87
from msgpack import unpackb
9-
if sys.version_info < (3, 8):
10-
from typing_extensions import Literal, Protocol
11-
else:
12-
from typing import Literal, Protocol
138

149
from pynvim.compat import unicode_errors_default
1510

pynvim/api/nvim.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from functools import partial
1010
from traceback import format_stack
1111
from types import SimpleNamespace
12-
from typing import (Any, AnyStr, Callable, Dict, Iterator, List, Optional,
12+
from typing import (Any, AnyStr, Callable, Dict, Iterator, List, Literal, Optional,
1313
TYPE_CHECKING, Union)
1414

1515
from msgpack import ExtType
@@ -24,11 +24,6 @@
2424
if TYPE_CHECKING:
2525
from pynvim.msgpack_rpc import Session
2626

27-
if sys.version_info < (3, 8):
28-
from typing_extensions import Literal
29-
else:
30-
from typing import Literal
31-
3227
__all__ = ['Nvim']
3328

3429

pynvim/compat.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,6 @@
33
from typing import Any, Dict, Optional
44

55

6-
def find_module(fullname, path): # type: ignore
7-
"""Compatibility wrapper for imp.find_module.
8-
9-
Automatically decodes arguments of find_module, in Python3
10-
they must be Unicode
11-
"""
12-
if isinstance(fullname, bytes):
13-
fullname = fullname.decode()
14-
if isinstance(path, bytes):
15-
path = path.decode()
16-
elif isinstance(path, list):
17-
newpath = []
18-
for element in path:
19-
if isinstance(element, bytes):
20-
newpath.append(element.decode())
21-
else:
22-
newpath.append(element)
23-
path = newpath
24-
from imp import find_module as original_find_module
25-
return original_find_module(fullname, path)
26-
27-
286
unicode_errors_default = 'surrogateescape'
297

308
NUM_TYPES = (int, float)

pynvim/msgpack_rpc/event_loop/base.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
"""Common code for event loop implementations."""
22
import logging
33
import signal
4-
import sys
54
import threading
65
from abc import ABC, abstractmethod
7-
from typing import Any, Callable, List, Optional, Union
8-
9-
if sys.version_info < (3, 8):
10-
from typing_extensions import Literal
11-
else:
12-
from typing import Literal
6+
from typing import Any, Callable, List, Literal, Optional, Union
137

148
logger = logging.getLogger(__name__)
159
debug, info, warn = (logger.debug, logger.info, logger.warning,)

pynvim/msgpack_rpc/session.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
"""Synchronous msgpack-rpc session layer."""
22
import logging
3-
import sys
43
import threading
54
from collections import deque
65
from traceback import format_exc
7-
from typing import (Any, AnyStr, Callable, Deque, List, NamedTuple, Optional, Sequence,
8-
Tuple, Union, cast)
6+
from typing import (Any, AnyStr, Callable, Deque, List, Literal, NamedTuple, Optional,
7+
Sequence, Tuple, Union, cast)
98

109
import greenlet
1110

1211
from pynvim.compat import check_async
1312
from pynvim.msgpack_rpc.async_session import AsyncSession
1413
from pynvim.msgpack_rpc.event_loop.base import BaseEventLoop
1514

16-
if sys.version_info < (3, 8):
17-
from typing_extensions import Literal
18-
else:
19-
from typing import Literal
20-
2115
logger = logging.getLogger(__name__)
2216
error, debug, info, warn = (logger.error, logger.debug, logger.info,
2317
logger.warning,)

pynvim/plugin/decorators.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,10 @@
22

33
import inspect
44
import logging
5-
import sys
6-
from typing import Any, Callable, Dict, Optional, TypeVar, Union
5+
from typing import Any, Callable, Dict, Literal, Optional, TypeVar, Union
76

87
from pynvim.compat import unicode_errors_default
98

10-
if sys.version_info < (3, 8):
11-
from typing_extensions import Literal
12-
else:
13-
from typing import Literal
14-
159
logger = logging.getLogger(__name__)
1610
debug, info, warn = (logger.debug, logger.info, logger.warning,)
1711
__all__ = ('plugin', 'rpc_export', 'command', 'autocmd', 'function',

pynvim/plugin/script_host.py

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -215,41 +215,7 @@ def _get_paths():
215215
return []
216216
return discover_runtime_directories(nvim)
217217

218-
def _find_module(fullname, oldtail, path):
219-
import imp
220-
idx = oldtail.find('.')
221-
if idx > 0:
222-
name = oldtail[:idx]
223-
tail = oldtail[idx + 1:]
224-
fmr = imp.find_module(name, path)
225-
module = imp.find_module(fullname[:-len(oldtail)] + name, *fmr)
226-
return _find_module(fullname, tail, module.__path__)
227-
else:
228-
return imp.find_module(fullname, path)
229-
230-
class VimModuleLoader(object):
231-
def __init__(self, module):
232-
self.module = module
233-
234-
def load_module(self, fullname, path=None):
235-
# Check sys.modules, required for reload (see PEP302).
236-
try:
237-
return sys.modules[fullname]
238-
except KeyError:
239-
pass
240-
import imp
241-
return imp.load_module(fullname, *self.module)
242-
243218
class VimPathFinder(object):
244-
@staticmethod
245-
def find_module(fullname, path=None):
246-
"""Method for Python 2.7 and 3.3."""
247-
try:
248-
return VimModuleLoader(
249-
_find_module(fullname, fullname, path or _get_paths()))
250-
except ImportError:
251-
return None
252-
253219
@staticmethod
254220
def find_spec(fullname, target=None):
255221
"""Method for Python 3.4+."""
@@ -258,8 +224,7 @@ def find_spec(fullname, target=None):
258224
def hook(path):
259225
if path == nvim.VIM_SPECIAL_PATH:
260226
return VimPathFinder
261-
else:
262-
raise ImportError
227+
raise ImportError
263228

264229
return hook
265230

0 commit comments

Comments
 (0)