Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# this path insert is needed for readthedocs.org (only)
sys.path.insert(
0, os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))
0, os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, "src"))
)

suppress_warnings = ["image.nonlocal_uri", "ref.class"]
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Issues = "https://github.com/jquast/telnetlib3/issues"

[tool.hatch.build.targets.sdist]
include = [
"/telnetlib3/**",
"/src/**",
"/docs/**",
"/README.rst",
"/CONTRIBUTING.rst",
Expand All @@ -85,7 +85,7 @@ include = [
]

[tool.hatch.build.targets.wheel]
packages = ["telnetlib3"]
packages = ["src/telnetlib.py", "src/telnetlib3"]

[tool.pylint.main]
load-plugins = [
Expand Down
11 changes: 11 additions & 0 deletions src/telnetlib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
Drop-in shim for telnetlib on 3.13+.

On Python 3.12 and earlier, `import telnetlib` should find the module in the standard library, but
in 3.13+, that standard module is removed. That should cause this shim to be found, which just
imports the (mostly) unadulterated copy this project vendors.
"""

# local
# pylint: disable=wildcard-import,unused-wildcard-import
from telnetlib3.telnetlib import * # noqa: F401, F403
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def init_subproc_coverage(run_note=None):
except ImportError:
return None

coveragerc = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, "tox.ini")
coveragerc = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, "tox.ini")
cov = coverage.Coverage(config_file=coveragerc)
cov.start()
return cov
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# 3rd party
import pytest

sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "bin"))
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "..", "bin"))
# 3rd party
import server_mud as mud

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
# std imports
import io
import re
import sys
import socket
import selectors
import sysconfig
import telnetlib as telnetlib_ # pylint: disable=deprecated-module
import threading
import contextlib

Expand Down Expand Up @@ -445,3 +448,10 @@ def test_expect(_mock_selector):
telnet = make_telnet(want)
_, _, data = telnet.expect([b"match"])
assert data == b"".join(want[:-1])


def test_drop_in_support():
"""Ensure `import telnetlib` works in Python 3.13+."""
telnetlib_in_stdlib = sys.version_info < (3, 13)
telnetlib_is_stdlib = telnetlib_.__file__.startswith(sysconfig.get_path("stdlib"))
assert telnetlib_is_stdlib == telnetlib_in_stdlib
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
47 changes: 24 additions & 23 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ deps =
trustme
usedevelop = True
commands =
pytest {posargs:--strict-markers --verbose --durations=10} telnetlib3/tests
pytest {posargs:--strict-markers --verbose --durations=10}



Expand All @@ -43,7 +43,7 @@ commands =
deps =
black
commands =
black telnetlib3/ bin/
black src/ bin/

[testenv:docformatter]
basepython = python3.13
Expand All @@ -57,7 +57,7 @@ commands =
--pre-summary-newline \
--wrap-summaries=100 \
--wrap-descriptions=100 \
{toxinidir}/telnetlib3/ \
{toxinidir}/src/ \
{toxinidir}/docs/conf.py

[testenv:docformatter_check]
Expand All @@ -73,14 +73,14 @@ commands =
--pre-summary-newline \
--wrap-summaries=100 \
--wrap-descriptions=100 \
{toxinidir}/telnetlib3/ \
{toxinidir}/src/ \
{toxinidir}/docs/conf.py

[testenv:flake8]
deps =
flake8
commands =
flake8 --exclude=tests telnetlib3/ bin/
flake8 --exclude=tests src/ bin/

[testenv:flake8_tests]
deps =
Expand All @@ -89,25 +89,25 @@ commands =
# F811: pytest fixtures appear as redefinitions
# E402: imports after conftest fixtures
# E712: comparison to False in tests is intentional
flake8 --ignore=W504,F401,E501,F811,E402,E712,F841,W503,E203 telnetlib3/tests/
flake8 --ignore=W504,F401,E501,F811,E402,E712,F841,W503,E203 src/telnetlib3/tests/

[testenv:isort]
deps =
isort
commands =
isort telnetlib3 bin
isort src bin

[testenv:isort_check]
deps =
isort
commands =
isort --diff --check-only telnetlib3 bin
isort --diff --check-only src bin

[testenv:mypy]
deps =
mypy
commands =
mypy --strict telnetlib3
mypy --strict src

[testenv:pydocstyle]
deps =
Expand All @@ -116,7 +116,7 @@ deps =
doc8
pygments
commands =
pydocstyle --source --explain {toxinidir}/telnetlib3
pydocstyle --source --explain {toxinidir}/src
rst-lint README.rst
doc8 --ignore-path docs/_build --ignore D000 docs

Expand All @@ -126,7 +126,7 @@ deps =
prettytable
ucs-detect>=2
commands =
pylint {posargs} telnetlib3 bin --ignore=tests
pylint {posargs} src bin --ignore=tests

[testenv:pylint_tests]
deps =
Expand All @@ -145,7 +145,7 @@ commands =
--disable=unpacking-non-sequence \
--disable=unused-import \
--disable=unused-variable \
{posargs} telnetlib3/tests
{posargs} src/telnetlib3/tests

[testenv:codespell]
deps =
Expand Down Expand Up @@ -201,26 +201,26 @@ commands =
[coverage:run]
branch = True
parallel = True
source = telnetlib3
omit = telnetlib3/tests/*
telnetlib3/telnetlib.py
telnetlib3/_types.py
source = src/telnetlib3
omit = src/telnetlib3/tests/*
src/telnetlib3/telnetlib.py
src/telnetlib3/_types.py
# Too complex for good coverage, though some tests exists, it
# is tested by running a public server: telnet 1984.ws 555
telnetlib3/fingerprinting_display.py
src/telnetlib3/fingerprinting_display.py
relative_files = True

[coverage:report]
precision = 1
exclude_lines =
pragma: no cover
omit = telnetlib3/tests/*
telnetlib3/telnetlib.py
telnetlib3/_types.py
telnetlib3/fingerprinting_display.py
omit = src/telnetlib3/tests/*
src/telnetlib3/telnetlib.py
src/telnetlib3/_types.py
src/telnetlib3/fingerprinting_display.py

[coverage:paths]
source = telnetlib3/
source = src/

[doc8]
max-line-length = 100
Expand Down Expand Up @@ -274,10 +274,11 @@ addopts =
--disable-pytest-warnings
--ignore=setup.py
--ignore=.tox
--ignore=telnetlib3/tests/test_benchmarks.py
--ignore=src/telnetlib3/tests/test_benchmarks.py
--durations=10
--timeout=15
--junit-xml=.tox/results.{envname}.xml
faulthandler_timeout = 30
filterwarnings =
junit_family = xunit1
testpaths = src/telnetlib3/tests
Loading