Skip to content

Commit d05599b

Browse files
authored
Merge branch 'trunk' into fix-chat-example
2 parents 9fb1257 + 234f378 commit d05599b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+543
-223
lines changed

.github/workflows/test.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,21 @@ jobs:
134134
# Just Python 3.11 with default settings.
135135
- python-version: '3.11'
136136

137+
# Just Python 3.13 alpha with default settings.
138+
# For now, no dependencies as cffi doesn't work on 3.13.
139+
# No coverage also.
140+
- python-version: '3.13.0-alpha.3'
141+
tox-env: 'nodeps-nocov-posix'
142+
job-name: 'nodeps-nocov-3.13'
143+
skip-coverage: yes
144+
# FIXME:https://github.com/twisted/twisted/issues/12060
145+
# Also add twisted.python
146+
# FIXME:https://github.com/twisted/twisted/issues/12061
147+
# Add full twisted.internet
148+
# FIXME:https://github.com/twisted/twisted/issues/12062
149+
# Add full twisted.test
150+
trial-target: 'twisted.conch twisted.cred twisted.logger twisted.mail twisted.names twisted.pair twisted.persisted twisted.protocols twisted.runner twisted.spread twisted.test.test_defer twisted.trial twisted.words'
151+
137152
# Newest macOS and oldest Python (major) supported versions.
138153
- python-version: '3.8'
139154
runs-on: 'macos-12'
@@ -168,7 +183,7 @@ jobs:
168183
# extension.
169184
# There is very little PYPY specific code so there is not much to
170185
# gain from reporting coverage.
171-
- python-version: 'pypy3.10-v7.3.13'
186+
- python-version: 'pypy3.10-v7.3.14'
172187
tox-env: 'alldeps-nocov-posix'
173188
job-name: 'no-coverage'
174189
skip-coverage: yes
@@ -194,7 +209,7 @@ jobs:
194209
- uses: actions/checkout@v3
195210

196211
- name: Set up Python
197-
uses: actions/setup-python@v4
212+
uses: actions/setup-python@v5
198213
with:
199214
python-version: ${{ matrix.python-version }}
200215
allow-prereleases: true

pyproject.toml

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ gtk-platform = [
126126

127127
mypy = [
128128
"twisted[dev,all-non-platform]",
129-
"mypy~=1.5.1",
130-
"mypy-zope~=1.0.1",
129+
"mypy~=1.8",
130+
"mypy-zope~=1.0.3",
131131
"types-setuptools",
132132
"types-pyOpenSSL",
133133
]
@@ -313,6 +313,80 @@ strict_equality = false
313313
no_implicit_reexport = false
314314
# Disable some checks until the effected modules fully adopt mypy
315315

316+
[[tool.mypy.overrides]]
317+
ignore_missing_imports = true
318+
follow_imports = "silent"
319+
follow_imports_for_stubs = true
320+
module = [
321+
322+
# pyobjc is not installed on linux
323+
"CFNetwork",
324+
"CoreFoundation",
325+
326+
# neither is pywin32
327+
"pywintypes",
328+
"win32api",
329+
"win32con",
330+
"win32com.*",
331+
"win32event",
332+
"win32file",
333+
"win32pipe",
334+
"win32process",
335+
"win32security",
336+
"win32console",
337+
338+
# pyserial is very optional
339+
"serial",
340+
"serial.*",
341+
342+
# GObject Introspection too
343+
"gi",
344+
"gi.repository.*",
345+
346+
# we need to clean this up, because it's ancient and probably unsupported,
347+
# but as long as it's still imported, we don't want to type-check it
348+
"gobject",
349+
"pygtk",
350+
"gtk",
351+
352+
# and wxPython
353+
"wxPython.wx",
354+
"wx",
355+
356+
# constantly doesn't have type stubs yet
357+
"constantly",
358+
359+
# h2 doesn't have types yet and is optional besides
360+
"h2.*",
361+
"hpack.*",
362+
"priority",
363+
364+
# subunit is untyped
365+
"subunit",
366+
367+
# oh this is fun, not even totally sure what library this is, since it's not
368+
# documented as an extra.
369+
"utmp",
370+
371+
# automat is not typed, or typeable, at least until
372+
# https://github.com/glyph/automat/pull/137 is landed
373+
"automat",
374+
375+
# I think only used by `twisted.web.script.ResourceTemplate`
376+
"quixote",
377+
378+
"cython_test_exception_raiser",
379+
380+
# various obscure database modules you shouldn't need installed in order to
381+
# type-check
382+
"pyPgSQL",
383+
"psycopg",
384+
"MySQLdb",
385+
"kinterbasdb",
386+
387+
"SOAPpy",
388+
]
389+
316390
[[tool.mypy.overrides]]
317391
allow_untyped_defs = true
318392
check_untyped_defs = false

src/twisted/application/internet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from random import random as _goodEnoughRandom
4242
from typing import List
4343

44-
from automat import MethodicalMachine # type: ignore[import]
44+
from automat import MethodicalMachine
4545

4646
from twisted.application import service
4747
from twisted.internet import task

src/twisted/application/runner/_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from typing import Any, Callable, Mapping, TextIO
1313

1414
from attr import Factory, attrib, attrs
15-
from constantly import NamedConstant # type: ignore[import]
15+
from constantly import NamedConstant
1616

1717
from twisted.internet.interfaces import IReactorCore
1818
from twisted.logger import (

src/twisted/conch/test/test_keys.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,8 +1675,8 @@ def test_providedArguments(self):
16751675
tempDir = FilePath(self.mktemp())
16761676
keyFile = tempDir.child("mykey.pem")
16771677

1678-
key = keys._getPersistentRSAKey(keyFile, keySize=512)
1679-
self.assertEqual(key.size(), 512)
1678+
key = keys._getPersistentRSAKey(keyFile, keySize=1024)
1679+
self.assertEqual(key.size(), 1024)
16801680
self.assertTrue(keyFile.exists())
16811681

16821682
def test_noRegeneration(self):
@@ -1687,15 +1687,15 @@ def test_noRegeneration(self):
16871687
tempDir = FilePath(self.mktemp())
16881688
keyFile = tempDir.child("mykey.pem")
16891689

1690-
key = keys._getPersistentRSAKey(keyFile, keySize=512)
1691-
self.assertEqual(key.size(), 512)
1690+
key = keys._getPersistentRSAKey(keyFile, keySize=1024)
1691+
self.assertEqual(key.size(), 1024)
16921692
self.assertTrue(keyFile.exists())
16931693
keyContent = keyFile.getContent()
16941694

1695-
# Set the key size to 1024 bits. Since it exists already, it will find
1696-
# the 512 bit key, and not generate a 1024 bit key.
1697-
key = keys._getPersistentRSAKey(keyFile, keySize=1024)
1698-
self.assertEqual(key.size(), 512)
1695+
# Set the key size to 2048 bits. Since it exists already, it will find
1696+
# the 1024 bit key, and not generate a 2048 bit key.
1697+
key = keys._getPersistentRSAKey(keyFile, keySize=2048)
1698+
self.assertEqual(key.size(), 1024)
16991699
self.assertEqual(keyFile.getContent(), keyContent)
17001700

17011701
def test_keySizeZero(self):
@@ -1706,6 +1706,6 @@ def test_keySizeZero(self):
17061706
tempDir = FilePath(self.mktemp())
17071707
keyFile = tempDir.child("mykey.pem")
17081708

1709-
key = keys._getPersistentRSAKey(keyFile, keySize=512)
1709+
key = keys._getPersistentRSAKey(keyFile, keySize=1024)
17101710
key._keyObject = None
17111711
self.assertEqual(key.size(), 0)

src/twisted/conch/test/test_manhole_tap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test_sshPort(self) -> None:
8080
"--sshKeyDir",
8181
self.mktemp(),
8282
"--sshKeySize",
83-
"512",
83+
"1024",
8484
"--sshPort",
8585
"tcp:223",
8686
]

src/twisted/conch/unix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
from twisted.python.compat import nativeString
4444

4545
try:
46-
import utmp # type: ignore[import]
46+
import utmp
4747
except ImportError:
4848
utmp = None
4949

src/twisted/internet/_dumbwin32proc.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212

1313
from zope.interface import implementer
1414

15-
import pywintypes # type: ignore[import]
15+
import pywintypes
1616

1717
# Win32 imports
18-
import win32api # type: ignore[import]
19-
import win32con # type: ignore[import]
20-
import win32event # type: ignore[import]
21-
import win32file # type: ignore[import]
22-
import win32pipe # type: ignore[import]
23-
import win32process # type: ignore[import]
24-
import win32security # type: ignore[import]
18+
import win32api
19+
import win32con
20+
import win32event
21+
import win32file
22+
import win32pipe
23+
import win32process
24+
import win32security
2525

2626
from twisted.internet import _pollingfile, error
2727
from twisted.internet._baseprocess import BaseProcess

src/twisted/internet/_glibbase.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from twisted.internet.interfaces import IReactorFDSet, IReadDescriptor, IWriteDescriptor
2323
from twisted.python import log
2424
from twisted.python.monkey import MonkeyPatcher
25-
from ._signals import _UnixWaker
25+
from ._signals import _IWaker, _UnixWaker
2626

2727

2828
def ensureNotImported(moduleNames, errorMessage, preventImports=[]):
@@ -77,7 +77,7 @@ def _signalGlue():
7777
reactor main loop which makes our signal handling work with glib's signal
7878
handling.
7979
"""
80-
from gi import _ossighelper as signalGlue # type: ignore[import]
80+
from gi import _ossighelper as signalGlue
8181

8282
patcher = MonkeyPatcher()
8383
patcher.addPatch(signalGlue, "_wakeup_fd_is_active", True)
@@ -129,7 +129,7 @@ class GlibReactorBase(posixbase.PosixReactorBase, posixbase._PollLikeMixin):
129129

130130
# Install a waker that knows it needs to call C{_simulate} in order to run
131131
# callbacks queued from a thread:
132-
def _wakerFactory(self) -> GlibWaker:
132+
def _wakerFactory(self) -> _IWaker:
133133
return GlibWaker(self)
134134

135135
def __init__(self, glib_module: Any, gtk_module: Any, useGtk: bool = False) -> None:

src/twisted/internet/_pollingfile.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ def _pollEvent(self):
9595
# If we ever (let's hope not) need the above functionality on UNIX, this could
9696
# be factored into a different module.
9797

98-
import pywintypes # type: ignore[import]
99-
import win32api # type: ignore[import]
100-
import win32file # type: ignore[import]
101-
import win32pipe # type: ignore[import]
98+
import pywintypes
99+
import win32api
100+
import win32file
101+
import win32pipe
102102

103103

104104
@implementer(IPushProducer)

src/twisted/internet/_posixserialport.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99

1010
# dependent on pyserial ( http://pyserial.sf.net/ )
1111
# only tested w/ 1.18 (5 Dec 2002)
12-
from serial import PARITY_NONE # type: ignore[import]
13-
from serial import EIGHTBITS, STOPBITS_ONE
12+
from serial import EIGHTBITS, PARITY_NONE, STOPBITS_ONE
1413

1514
from twisted.internet import abstract, fdesc
1615
from twisted.internet.serialport import BaseSerialPort

src/twisted/internet/_signals.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,12 @@ class _IWaker(Interface):
271271

272272
disconnected = Attribute("")
273273

274-
def wakeUp():
274+
def wakeUp() -> None:
275275
"""
276276
Called when the event should be wake up.
277277
"""
278278

279-
def doRead():
279+
def doRead() -> None:
280280
"""
281281
Read some data from my connection and discard it.
282282
"""

src/twisted/internet/_sslverify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from OpenSSL._util import lib as pyOpenSSLlib
1717

1818
import attr
19-
from constantly import FlagConstant, Flags, NamedConstant, Names # type: ignore[import]
19+
from constantly import FlagConstant, Flags, NamedConstant, Names
2020
from incremental import Version
2121

2222
from twisted.internet.abstract import isIPAddress, isIPv6Address

src/twisted/internet/_win32serialport.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010
"""
1111

1212

13-
import win32event # type: ignore[import]
14-
import win32file # type: ignore[import]
13+
import win32event
14+
import win32file
1515

1616
# system imports
17-
from serial import PARITY_NONE # type: ignore[import]
18-
from serial import EIGHTBITS, STOPBITS_ONE
19-
from serial.serialutil import to_bytes # type: ignore[import]
17+
from serial import EIGHTBITS, PARITY_NONE, STOPBITS_ONE
18+
from serial.serialutil import to_bytes
2019

2120
# twisted imports
2221
from twisted.internet import abstract

src/twisted/internet/_win32stdio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from zope.interface import implementer
1212

13-
import win32api # type: ignore[import]
13+
import win32api
1414

1515
from twisted.internet import _pollingfile, main
1616
from twisted.internet.interfaces import (

src/twisted/internet/cfreactor.py

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

1818
from zope.interface import implementer
1919

20-
from CFNetwork import ( # type: ignore[import]
20+
from CFNetwork import (
2121
CFSocketCreateRunLoopSource,
2222
CFSocketCreateWithNative,
2323
CFSocketDisableCallBacks,
@@ -30,7 +30,7 @@
3030
kCFSocketReadCallBack,
3131
kCFSocketWriteCallBack,
3232
)
33-
from CoreFoundation import ( # type: ignore[import]
33+
from CoreFoundation import (
3434
CFAbsoluteTimeGetCurrent,
3535
CFRunLoopAddSource,
3636
CFRunLoopAddTimer,

0 commit comments

Comments
 (0)