Bump pyright to 1.1.394 (#3283)

This commit is contained in:
Alexander Kukushkin
2025-02-19 17:04:19 +01:00
committed by GitHub
parent 7531d41587
commit cf427e8b0b
8 changed files with 29 additions and 14 deletions
+3 -3
View File
@@ -188,17 +188,17 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: 3.12
python-version: 3.13
- name: Install dependencies
run: python -m pip install -r requirements.txt psycopg2-binary psycopg
- uses: jakebailey/pyright-action@v2
with:
version: 1.1.391
version: 1.1.394
ydiff:
name: Test compatibility with the latest version of ydiff
+5 -2
View File
@@ -1609,13 +1609,16 @@ class RestApiServer(ThreadingMixIn, HTTPServer, Thread):
if hostname in ('', '*'):
hostname = None
info = socket.getaddrinfo(hostname, port, socket.AF_UNSPEC, socket.SOCK_STREAM, 0, socket.AI_PASSIVE)
# Filter out unexpected results when python is compiled with --disable-ipv6 and running on IPv6 system.
info = [(a[0], a[4][0], a[4][1])
for a in socket.getaddrinfo(hostname, port, socket.AF_UNSPEC, socket.SOCK_STREAM, 0, socket.AI_PASSIVE)
if isinstance(a[4][0], str) and isinstance(a[4][1], int)]
# in case dual stack is not supported we want IPv4 to be preferred over IPv6
info.sort(key=lambda x: x[0] == socket.AF_INET, reverse=not dual_stack)
self.address_family = info[0][0]
try:
HTTPServer.__init__(self, info[0][-1][:2], RestApiHandler)
HTTPServer.__init__(self, (info[0][1], info[0][2]), RestApiHandler)
except socket.error:
logger.error(
"Couldn't start a service on '%s:%s', please check your `restapi.listen` configuration", hostname, port)
+4 -2
View File
@@ -59,8 +59,10 @@ def get_address() -> Tuple[str, str]:
hostname = None
try:
hostname = socket.gethostname()
return hostname, sorted(socket.getaddrinfo(hostname, 0, socket.AF_UNSPEC, socket.SOCK_STREAM, 0),
key=lambda x: x[0])[0][4][0]
# Filter out unexpected results when python is compiled with --disable-ipv6 and running on IPv6 system.
addrs = [(a[0], a[4][0]) for a in socket.getaddrinfo(hostname, 0, socket.AF_UNSPEC, socket.SOCK_STREAM, 0)
if isinstance(a[4][0], str)]
return hostname, sorted(addrs, key=lambda x: x[0])[0][1]
except Exception as err:
logging.warning('Failed to obtain address: %r', err)
return NO_VALUE_MSG, NO_VALUE_MSG
+5 -2
View File
@@ -45,7 +45,8 @@ class EtcdError(DCSError):
pass
_AddrInfo = Tuple[socket.AddressFamily, socket.SocketKind, int, str, Union[Tuple[str, int], Tuple[str, int, int, int]]]
_AddrInfo = Tuple[socket.AddressFamily, socket.SocketKind, int, str,
Union[Tuple[str, int], Tuple[str, int, int, int], Tuple[int, bytes]]]
class DnsCachingResolver(Thread):
@@ -350,7 +351,9 @@ class AbstractEtcdClientWithFailover(abc.ABC, etcd.Client):
def _get_machines_cache_from_dns(self, host: str, port: int) -> List[str]:
"""One host might be resolved into multiple ip addresses. We will make list out of it"""
if self.protocol == 'http':
ret = [uri(self.protocol, res[-1][:2]) for res in self._dns_resolver.resolve(host, port)]
# Filter out unexpected results when python is compiled with --disable-ipv6 and running on IPv6 system.
ret = [uri(self.protocol, (res[4][0], res[4][1])) for res in self._dns_resolver.resolve(host, port)
if isinstance(res[4][0], str) and isinstance(res[4][1], int)]
if ret:
return list(set(ret))
return [uri(self.protocol, (host, port))]
+2 -1
View File
@@ -593,7 +593,8 @@ class ConfigHandler(object):
if 'host' in self.local_replication_address and not self.local_replication_address['host'].startswith('/'):
addresses.update({sa[0] + '/32': 'host' for _, _, _, _, sa in socket.getaddrinfo(
self.local_replication_address['host'], self.local_replication_address['port'],
0, socket.SOCK_STREAM, socket.IPPROTO_TCP)})
0, socket.SOCK_STREAM, socket.IPPROTO_TCP) if isinstance(sa[0], str)})
# Filter out unexpected results when python is compiled with --disable-ipv6 and running on IPv6 system.
with self.config_writer(self._pg_hba_conf) as f:
for address, t in addresses.items():
+5 -2
View File
@@ -138,11 +138,14 @@ def validate_host_port(host_port: str, listen: bool = False, multiple_hosts: boo
hosts = hosts.split(",")
else:
hosts = [hosts]
# If host is set to "*" get all hostnames and/or IP addresses that the host would be able to listen to
if "*" in hosts:
if len(hosts) != 1:
raise ConfigParseError("expecting '*' alone")
# If host is set to "*" get all hostnames and/or IP addresses that the host would be able to listen to
hosts = [p[-1][0] for p in socket.getaddrinfo(None, port, 0, socket.SOCK_STREAM, 0, socket.AI_PASSIVE)]
# Filter out unexpected results when python is compiled with --disable-ipv6 and running on IPv6 system.
hosts = [a[4][0] for a in socket.getaddrinfo(None, port, 0, socket.SOCK_STREAM, 0, socket.AI_PASSIVE)
if isinstance(a[4][0], str)]
for host in hosts:
# Check if "socket.IF_INET" or "socket.IF_INET6" is being used and instantiate a socket with the identified
# protocol
+1 -1
View File
@@ -19,7 +19,7 @@
"reportMissingImports": true,
"reportMissingTypeStubs": false,
"pythonVersion": "3.12",
"pythonVersion": "3.13",
"pythonPlatform": "All",
"typeCheckingMode": "strict"
+4 -1
View File
@@ -352,7 +352,10 @@ class TestGenerateConfig(unittest.TestCase):
self.assertIn('Unexpected exception', e.exception.code)
def test_get_address(self):
with patch('socket.getaddrinfo', Mock(side_effect=Exception)), \
with patch('socket.getaddrinfo', Mock(side_effect=[[(2, 1, 6, '', ('127.0.0.1', 0))],
Exception])), \
patch('socket.gethostname', Mock(return_value='foo')), \
patch('logging.warning') as mock_warning:
self.assertEqual(get_address(), ('foo', '127.0.0.1'))
self.assertEqual(get_address(), (NO_VALUE_MSG, NO_VALUE_MSG))
self.assertIn('Failed to obtain address: %r', mock_warning.call_args_list[0][0])