Skip to content

Commit 136b47b

Browse files
apotterridustinbyrne
authored andcommitted
fix: support python 3.12
3.12 removed inpect._is_type. Use the old implementation in importer.is_class. Also, tweak dependencies so our tests run in a 3.12 environment.
1 parent da925c8 commit 136b47b

File tree

6 files changed

+16
-11
lines changed

6 files changed

+16
-11
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ os: linux
22
dist: jammy
33
language: python
44
python:
5+
- "3.12"
56
- "3.11"
67
- "3.10"
78
- "3.9.14"

_appmap/importer.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ def is_class(c):
8989
# bound to __class__. (For example, celery.local.Proxy uses this
9090
# mechanism to return the class of the proxied object.)
9191
#
92-
return inspect._is_type(c) # pylint: disable=protected-access
92+
try:
93+
inspect._static_getmro(c) # pylint: disable=protected-access
94+
except TypeError:
95+
return False
96+
return True
9397

9498

9599
def get_classes(module):
@@ -173,7 +177,6 @@ def instrument_functions(filterable, selected_functions=None):
173177
logger.debug(" functions %s", functions)
174178

175179
for fn_name, static_fn, fn in functions:
176-
177180
# Only instrument the function if it was specifically called out for the package
178181
# (e.g. because it should be labeled), or it's included by the filters
179182
filterableFn = FilterableFn(filterable, fn, static_fn)

pyproject.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,15 @@ packaging = ">=19.0"
5353

5454
[tool.poetry.dev-dependencies]
5555
httpretty = "^1.0.5"
56-
pytest = "^6.1.2"
56+
pytest = "^7.3.2"
5757
pytest-randomly = "^3.5.0"
5858
pylint = "^2.6.0"
59-
pytest-django = "~ 4.5.2"
59+
pytest-django = [
60+
{ version = "~4.7", python = ">=3.8" },
61+
{ version = "<4.7", python = "3.7" }
62+
]
6063
flake8 = "^3.8.4"
61-
pyfakefs = "^4.3.2"
64+
pyfakefs = "^5.3.5"
6265
pprintpp = ">=0.4.0"
6366
coverage = "^5.3"
6467
pytest-mock = "^3.5.1"

requirements-dev.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#requirements-dev.txt
2-
pip
3-
poetry
42
tox
53
django
64
flask
7-
pytest-django
5+
pytest-django<4.8

requirements-test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
django ~= 3.2
2-
pytest-django
2+
pytest-django < 4.8

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
isolated_build = true
33
# The *-web environments test the latest versions of Django and Flask with the full test suite. For
44
# older version of the web frameworks, just run the tests that are specific to them.
5-
envlist = py3{8,9,10,11}-web, py3{7,8,9,10,11}-flask1-django3
5+
envlist = py3{8,9,10,11,12}-web, py3{7,8,9,10,11,12}-flask1-django3
66

77
[testenv]
88
allowlist_externals =
99
env
1010
poetry
1111

1212
deps=
13-
pytest-django >=4.5.2, <4.6
13+
pytest-django <4.8
1414
web: Django >=4.0, <5.0
1515
web: Flask >= 2
1616
flask1: -rrequirements-flask1.txt

0 commit comments

Comments
 (0)