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: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Set up Python 3.12 - name: Set up Python 3.13
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: 3.12 python-version: 3.13
- name: Install dependencies - name: Install dependencies
run: python -m pip install -r requirements.txt psycopg2-binary psycopg run: python -m pip install -r requirements.txt psycopg2-binary psycopg
- uses: jakebailey/pyright-action@v2 - uses: jakebailey/pyright-action@v2
with: with:
version: 1.1.391 version: 1.1.394
ydiff: ydiff:
name: Test compatibility with the latest version of 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 ('', '*'): if hostname in ('', '*'):
hostname = None 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 # 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) info.sort(key=lambda x: x[0] == socket.AF_INET, reverse=not dual_stack)
self.address_family = info[0][0] self.address_family = info[0][0]
try: try:
HTTPServer.__init__(self, info[0][-1][:2], RestApiHandler) HTTPServer.__init__(self, (info[0][1], info[0][2]), RestApiHandler)
except socket.error: except socket.error:
logger.error( logger.error(
"Couldn't start a service on '%s:%s', please check your `restapi.listen` configuration", hostname, port) "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 hostname = None
try: try:
hostname = socket.gethostname() hostname = socket.gethostname()
return hostname, sorted(socket.getaddrinfo(hostname, 0, socket.AF_UNSPEC, socket.SOCK_STREAM, 0), # Filter out unexpected results when python is compiled with --disable-ipv6 and running on IPv6 system.
key=lambda x: x[0])[0][4][0] 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: except Exception as err:
logging.warning('Failed to obtain address: %r', err) logging.warning('Failed to obtain address: %r', err)
return NO_VALUE_MSG, NO_VALUE_MSG return NO_VALUE_MSG, NO_VALUE_MSG
+5 -2
View File
@@ -45,7 +45,8 @@ class EtcdError(DCSError):
pass 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): 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]: 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""" """One host might be resolved into multiple ip addresses. We will make list out of it"""
if self.protocol == 'http': 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: if ret:
return list(set(ret)) return list(set(ret))
return [uri(self.protocol, (host, port))] 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('/'): 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( addresses.update({sa[0] + '/32': 'host' for _, _, _, _, sa in socket.getaddrinfo(
self.local_replication_address['host'], self.local_replication_address['port'], 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: with self.config_writer(self._pg_hba_conf) as f:
for address, t in addresses.items(): 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(",") hosts = hosts.split(",")
else: else:
hosts = [hosts] 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 "*" in hosts:
if len(hosts) != 1: if len(hosts) != 1:
raise ConfigParseError("expecting '*' alone") 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 # Filter out unexpected results when python is compiled with --disable-ipv6 and running on IPv6 system.
hosts = [p[-1][0] for p in socket.getaddrinfo(None, port, 0, socket.SOCK_STREAM, 0, socket.AI_PASSIVE)] 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: for host in hosts:
# Check if "socket.IF_INET" or "socket.IF_INET6" is being used and instantiate a socket with the identified # Check if "socket.IF_INET" or "socket.IF_INET6" is being used and instantiate a socket with the identified
# protocol # protocol
+1 -1
View File
@@ -19,7 +19,7 @@
"reportMissingImports": true, "reportMissingImports": true,
"reportMissingTypeStubs": false, "reportMissingTypeStubs": false,
"pythonVersion": "3.12", "pythonVersion": "3.13",
"pythonPlatform": "All", "pythonPlatform": "All",
"typeCheckingMode": "strict" "typeCheckingMode": "strict"
+4 -1
View File
@@ -352,7 +352,10 @@ class TestGenerateConfig(unittest.TestCase):
self.assertIn('Unexpected exception', e.exception.code) self.assertIn('Unexpected exception', e.exception.code)
def test_get_address(self): 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: 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.assertEqual(get_address(), (NO_VALUE_MSG, NO_VALUE_MSG))
self.assertIn('Failed to obtain address: %r', mock_warning.call_args_list[0][0]) self.assertIn('Failed to obtain address: %r', mock_warning.call_args_list[0][0])