Skip to content

Commit 5c4441e

Browse files
authored
Clean up deprecations (#650)
1 parent 3e78339 commit 5c4441e

File tree

11 files changed

+30
-170
lines changed

11 files changed

+30
-170
lines changed

.github/workflows/integration-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
os: [ubuntu]
14-
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "pypy3"]
14+
python-version: ["3.7", "3.8", "3.9", "3.10", "pypy-3.7"]
1515
steps:
1616
- name: Checkout
1717
uses: actions/checkout@v2

.github/workflows/python-linux.yml

+9-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
fail-fast: false
3636
matrix:
3737
os: [ubuntu]
38-
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "pypy3"]
38+
python-version: ["3.7", "3.8", "3.9", "3.10", "pypy-3.7"]
3939
steps:
4040
- name: Checkout
4141
uses: actions/checkout@v2
@@ -49,11 +49,11 @@ jobs:
4949
pip freeze
5050
pip check
5151
- name: Run the tests
52-
if: ${{ matrix.python-version != 'pypy3' }}
52+
if: ${{ matrix.python-version != 'pypy-3.7' }}
5353
run: |
5454
pytest -vv jupyter_server --cov jupyter_server --cov-branch --cov-report term-missing:skip-covered
5555
- name: Run the tests on pypy
56-
if: ${{ matrix.python-version == 'pypy3' }}
56+
if: ${{ matrix.python-version == 'pypy-3.7' }}
5757
run: |
5858
pytest -vv jupyter_server
5959
- name: Install the Python dependencies for the examples
@@ -63,7 +63,7 @@ jobs:
6363
run: |
6464
pytest examples/simple
6565
- name: Coverage
66-
if: ${{ matrix.python-version != 'pypy3' }}
66+
if: ${{ matrix.python-version != 'pypy-3.7' }}
6767
run: |
6868
codecov
6969
- name: Test full install
@@ -74,3 +74,8 @@ jobs:
7474
pushd test_install
7575
./bin/pytest --pyargs jupyter_server
7676
popd
77+
- name: Test the docs
78+
run: |
79+
cd docs
80+
pip install -r doc-requirements.txt
81+
make html SPHINXOPTS="-W"

.github/workflows/python-macos.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
os: [macos]
14-
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "pypy-3.7"]
14+
python-version: ["3.7", "3.8", "3.9", "3.10", "pypy-3.7"]
1515
steps:
1616
- name: Checkout
1717
uses: actions/checkout@v2

.github/workflows/python-windows.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
os: [windows]
14-
python-version: ["3.6", "3.7", "3.8", "3.9"]
14+
python-version: ["3.7", "3.8", "3.9", "3.10"]
1515
steps:
1616
- name: Checkout
1717
uses: actions/checkout@v2

docs/environment.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: jupyter_server_docs
22
dependencies:
3-
- nodejs=14
4-
- python=3.8
3+
- nodejs
4+
- python
55
- pip
66
- pip:
77
- -r doc-requirements.txt

docs/source/conf.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
import shutil
1818
import sys
1919

20+
from pkg_resources import parse_version
21+
22+
2023
HERE = osp.abspath(osp.dirname(__file__))
2124

2225

@@ -106,13 +109,10 @@
106109
# |version| and |release|, also used in various other places throughout the
107110
# built documents.
108111
#
109-
_version_py = "../../jupyter_server/_version.py"
110-
version_ns = {}
111-
exec(compile(open(_version_py).read(), _version_py, "exec"), version_ns)
112+
__version__ = "1.14.0.dev0"
112113
# The short X.Y version.
113-
version = "%i.%i" % version_ns["version_info"][:2]
114-
# The full version, including alpha/beta/rc tags.
115-
release = version_ns["__version__"]
114+
version_parsed = parse_version(__version__)
115+
version = f"{version_parsed.major}.{version_parsed.minor}"
116116

117117
# The language for content autogenerated by Sphinx. Refer to documentation
118118
# for a list of supported languages.
@@ -336,7 +336,7 @@
336336

337337
# -- Options for link checks ----------------------------------------------
338338

339-
linkcheck_ignore = ["http://127\.0\.0\.1/*"]
339+
linkcheck_ignore = [r"http://127\.0\.0\.1/*"]
340340

341341

342342
# -- Options for Texinfo output -------------------------------------------

examples/simple/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def add_data_files(path):
3434
version=VERSION,
3535
description="Jupyter Server Example",
3636
long_description=open("README.md").read(),
37-
python_requires=">=3.6",
37+
python_requires=">=3.7",
3838
install_requires=[
3939
"jupyter_server",
4040
"jinja2",

jupyter_server/gateway/gateway_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def _headers_default(self):
232232
default_value=None,
233233
allow_none=True,
234234
config=True,
235-
help="""The authorization token used in the HTTP headers. The header will be formatted as:
235+
help="""The authorization token used in the HTTP headers. The header will be formatted as::
236236
237237
{
238238
'Authorization': '{auth_scheme} {auth_token}'

jupyter_server/traittypes.py

+1-147
Original file line numberDiff line numberDiff line change
@@ -4,153 +4,7 @@
44
from traitlets import ClassBasedTraitType
55
from traitlets import TraitError
66
from traitlets import Undefined
7-
8-
# Traitlet's 5.x includes a set of utilities for building
9-
# description strings for objects. Traitlets 5.x does not
10-
# support Python 3.6, but jupyter_server does; instead
11-
# jupyter_server uses traitlets 4.3.x which doesn't have
12-
# this `descriptions` submodule. This chunk in the except
13-
# clause is a copy-and-paste from traitlets 5.0.5.
14-
try:
15-
from traitlets.utils.descriptions import describe
16-
except ImportError:
17-
import re
18-
import types
19-
20-
def describe(article, value, name=None, verbose=False, capital=False):
21-
"""Return string that describes a value
22-
Parameters
23-
----------
24-
article : str or None
25-
A definite or indefinite article. If the article is
26-
indefinite (i.e. "a" or "an") the appropriate one
27-
will be infered. Thus, the arguments of ``describe``
28-
can themselves represent what the resulting string
29-
will actually look like. If None, then no article
30-
will be prepended to the result. For non-articled
31-
description, values that are instances are treated
32-
definitely, while classes are handled indefinitely.
33-
value : any
34-
The value which will be named.
35-
name : str or None (default: None)
36-
Only applies when ``article`` is "the" - this
37-
``name`` is a definite reference to the value.
38-
By default one will be infered from the value's
39-
type and repr methods.
40-
verbose : bool (default: False)
41-
Whether the name should be concise or verbose. When
42-
possible, verbose names include the module, and/or
43-
class name where an object was defined.
44-
capital : bool (default: False)
45-
Whether the first letter of the article should
46-
be capitalized or not. By default it is not.
47-
Examples
48-
--------
49-
Indefinite description:
50-
>>> describe("a", object())
51-
'an object'
52-
>>> describe("a", object)
53-
'an object'
54-
>>> describe("a", type(object))
55-
'a type'
56-
57-
Definite description:
58-
>>> describe("the", object()) # doctest: +ELLIPSIS
59-
"the object at '0x...'"
60-
>>> describe("the", object)
61-
'the object object'
62-
>>> describe("the", type(object))
63-
'the type type'
64-
65-
Definitely named description:
66-
>>> describe("the", object(), "I made")
67-
'the object I made'
68-
>>> describe("the", object, "I will use")
69-
'the object I will use'
70-
"""
71-
if isinstance(article, str):
72-
article = article.lower()
73-
74-
if not inspect.isclass(value):
75-
typename = type(value).__name__
76-
else:
77-
typename = value.__name__
78-
if verbose:
79-
typename = _prefix(value) + typename
80-
81-
if article == "the" or (article is None and not inspect.isclass(value)):
82-
if name is not None:
83-
result = "{} {}".format(typename, name)
84-
if article is not None:
85-
return add_article(result, True, capital)
86-
else:
87-
return result
88-
else:
89-
tick_wrap = False
90-
if inspect.isclass(value):
91-
name = value.__name__
92-
elif isinstance(value, types.FunctionType):
93-
name = value.__name__
94-
tick_wrap = True
95-
elif isinstance(value, types.MethodType):
96-
name = value.__func__.__name__
97-
tick_wrap = True
98-
elif type(value).__repr__ in (object.__repr__, type.__repr__):
99-
name = "at '%s'" % hex(id(value))
100-
verbose = False
101-
else:
102-
name = repr(value)
103-
verbose = False
104-
if verbose:
105-
name = _prefix(value) + name
106-
if tick_wrap:
107-
name = name.join("''")
108-
return describe(article, value, name=name, verbose=verbose, capital=capital)
109-
elif article in ("a", "an") or article is None:
110-
if article is None:
111-
return typename
112-
return add_article(typename, False, capital)
113-
else:
114-
raise ValueError(
115-
"The 'article' argument should " "be 'the', 'a', 'an', or None not %r" % article
116-
)
117-
118-
def add_article(name, definite=False, capital=False):
119-
"""Returns the string with a prepended article.
120-
The input does not need to begin with a charater.
121-
Parameters
122-
----------
123-
definite : bool (default: False)
124-
Whether the article is definite or not.
125-
Indefinite articles being 'a' and 'an',
126-
while 'the' is definite.
127-
capital : bool (default: False)
128-
Whether the added article should have
129-
its first letter capitalized or not.
130-
"""
131-
if definite:
132-
result = "the " + name
133-
else:
134-
first_letters = re.compile(r"[\W_]+").sub("", name)
135-
if first_letters[:1].lower() in "aeiou":
136-
result = "an " + name
137-
else:
138-
result = "a " + name
139-
if capital:
140-
return result[0].upper() + result[1:]
141-
else:
142-
return result
143-
144-
def _prefix(value):
145-
if isinstance(value, types.MethodType):
146-
name = describe(None, value.__self__, verbose=True) + "."
147-
else:
148-
module = inspect.getmodule(value)
149-
if module is not None and module.__name__ != "builtins":
150-
name = module.__name__ + "."
151-
else:
152-
name = ""
153-
return name
7+
from traitlets.utils.descriptions import describe
1548

1559

15610
class TypeFromClasses(ClassBasedTraitType):

jupyter_server/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import sys
1111
from _frozen_importlib_external import _NamespacePath
1212
from contextlib import contextmanager
13-
from distutils.version import LooseVersion
1413
from urllib.parse import quote
1514
from urllib.parse import SplitResult
1615
from urllib.parse import unquote
@@ -20,6 +19,7 @@
2019
from urllib.parse import urlunsplit
2120
from urllib.request import pathname2url # noqa: F401
2221

22+
from packaging.version import Version
2323
from tornado.httpclient import AsyncHTTPClient
2424
from tornado.httpclient import HTTPClient
2525
from tornado.httpclient import HTTPRequest
@@ -143,7 +143,7 @@ def check_version(v, check):
143143
Users on dev branches are responsible for keeping their own packages up to date.
144144
"""
145145
try:
146-
return LooseVersion(v) >= LooseVersion(check)
146+
return Version(v) >= Version(check)
147147
except TypeError:
148148
return True
149149

setup.cfg

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = attr: jupyter_server.__version__
44
description = The backend—i.e. core services, APIs, and REST endpoints—to Jupyter web applications.
55
long_description = file: README.md
66
long_description_content_type = text/markdown
7-
license_file = COPYING.md
7+
license_files = COPYING.md
88
author = Jupyter Development Team
99
author_email = [email protected]
1010
url = https://jupyter.org
@@ -16,16 +16,16 @@ classifiers =
1616
Intended Audience :: Science/Research
1717
License :: OSI Approved :: BSD License
1818
Programming Language :: Python
19-
Programming Language :: Python :: 3.6
2019
Programming Language :: Python :: 3.7
2120
Programming Language :: Python :: 3.8
2221
Programming Language :: Python :: 3.9
22+
Programming Language :: Python :: 3.10
2323

2424
[options]
2525
zip_safe = False
2626
include_package_data = True
2727
packages = find:
28-
python_requires = >=3.6
28+
python_requires = >=3.7
2929
install_requires =
3030
jinja2
3131
tornado>=6.1.0
@@ -42,6 +42,7 @@ install_requires =
4242
prometheus_client
4343
anyio>=3.1.0,<4
4444
websocket-client
45+
packaging
4546

4647
[options.extras_require]
4748
test =

0 commit comments

Comments
 (0)