6
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-12-12 22:27:47 +00:00

feat: upgrade pinned requirements to click 8+

We were forced to pin click to < v8 because of missing dependencies. In
particular, click_repl was broken. This is no longer the case, as click_repl
0.20 was published. Also, Jinja2 now includes type annotations, which allows us
to get rid of a few "# type: ignore" statements.

We take the opportunity to upgrade all requirements, which allows us resolve a
security issue on urllib3<1.26.0.
This commit is contained in:
Régis Behmo 2021-06-02 15:16:32 +02:00 committed by Régis Behmo
parent a79d194bbc
commit e990291d16
6 changed files with 54 additions and 71 deletions

View File

@ -1,13 +1,8 @@
appdirs appdirs
click>=7.0,<8.0 click
click_repl click_repl
mypy mypy
pycryptodome pycryptodome
jinja2>=2.9,<3.0 jinja2
kubernetes kubernetes
pyyaml>=4.2b1 pyyaml>=4.2b1
# Add constraints until we are compatible with click 8.0
markupsafe<2.0
# Installing urllib3==1.26.0 causes compatibility errors with requests==2.24.0
urllib3<1.26.0

View File

@ -8,35 +8,33 @@ appdirs==1.4.4
# via -r requirements/base.in # via -r requirements/base.in
cachetools==4.2.2 cachetools==4.2.2
# via google-auth # via google-auth
certifi==2020.12.5 certifi==2021.5.30
# via # via
# kubernetes # kubernetes
# requests # requests
chardet==4.0.0 chardet==4.0.0
# via requests # via requests
click-repl==0.1.6 click-repl==0.2.0
# via -r requirements/base.in # via -r requirements/base.in
click==7.1.2 click==8.0.1
# via # via
# -r requirements/base.in # -r requirements/base.in
# click-repl # click-repl
google-auth==1.30.0 google-auth==1.30.1
# via kubernetes # via kubernetes
idna==2.10 idna==2.10
# via requests # via requests
jinja2==2.11.3 jinja2==3.0.1
# via -r requirements/base.in # via -r requirements/base.in
kubernetes==12.0.1 kubernetes==17.17.0
# via -r requirements/base.in # via -r requirements/base.in
markupsafe==1.1.1 markupsafe==2.0.1
# via # via jinja2
# -r requirements/base.in
# jinja2
mypy-extensions==0.4.3 mypy-extensions==0.4.3
# via mypy # via mypy
mypy==0.812 mypy==0.812
# via -r requirements/base.in # via -r requirements/base.in
oauthlib==3.1.0 oauthlib==3.1.1
# via requests-oauthlib # via requests-oauthlib
prompt-toolkit==3.0.18 prompt-toolkit==3.0.18
# via click-repl # via click-repl
@ -68,19 +66,17 @@ six==1.16.0
# google-auth # google-auth
# kubernetes # kubernetes
# python-dateutil # python-dateutil
# websocket-client
typed-ast==1.4.3 typed-ast==1.4.3
# via mypy # via mypy
typing-extensions==3.10.0.0 typing-extensions==3.10.0.0
# via mypy # via mypy
urllib3==1.25.11 urllib3==1.26.5
# via # via
# -r requirements/base.in
# kubernetes # kubernetes
# requests # requests
wcwidth==0.2.5 wcwidth==0.2.5
# via prompt-toolkit # via prompt-toolkit
websocket-client==0.59.0 websocket-client==1.0.1
# via kubernetes # via kubernetes
# The following packages are considered to be unsafe in a requirements file: # The following packages are considered to be unsafe in a requirements file:

View File

@ -12,7 +12,7 @@ appdirs==1.4.4
# black # black
astroid==2.5.6 astroid==2.5.6
# via pylint # via pylint
black==21.5b1 black==21.5b2
# via -r requirements/dev.in # via -r requirements/dev.in
bleach==3.3.0 bleach==3.3.0
# via readme-renderer # via readme-renderer
@ -20,7 +20,7 @@ cachetools==4.2.2
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# google-auth # google-auth
certifi==2020.12.5 certifi==2021.5.30
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# kubernetes # kubernetes
@ -31,9 +31,9 @@ chardet==4.0.0
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# requests # requests
click-repl==0.1.6 click-repl==0.2.0
# via -r requirements/base.txt # via -r requirements/base.txt
click==7.1.2 click==8.0.1
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# black # black
@ -45,7 +45,7 @@ cryptography==3.4.7
# via secretstorage # via secretstorage
docutils==0.17.1 docutils==0.17.1
# via readme-renderer # via readme-renderer
google-auth==1.30.0 google-auth==1.30.1
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# kubernetes # kubernetes
@ -53,11 +53,9 @@ idna==2.10
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# requests # requests
importlib-metadata==4.0.1 importlib-metadata==4.4.0
# via # via
# keyring # keyring
# pep517
# pyinstaller
# twine # twine
isort==5.8.0 isort==5.8.0
# via pylint # via pylint
@ -65,15 +63,15 @@ jeepney==0.6.0
# via # via
# keyring # keyring
# secretstorage # secretstorage
jinja2==2.11.3 jinja2==3.0.1
# via -r requirements/base.txt # via -r requirements/base.txt
keyring==23.0.1 keyring==23.0.1
# via twine # via twine
kubernetes==12.0.1 kubernetes==17.17.0
# via -r requirements/base.txt # via -r requirements/base.txt
lazy-object-proxy==1.6.0 lazy-object-proxy==1.6.0
# via astroid # via astroid
markupsafe==1.1.1 markupsafe==2.0.1
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# jinja2 # jinja2
@ -86,7 +84,7 @@ mypy-extensions==0.4.3
# mypy # mypy
mypy==0.812 mypy==0.812
# via -r requirements/base.txt # via -r requirements/base.txt
oauthlib==3.1.0 oauthlib==3.1.1
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# requests-oauthlib # requests-oauthlib
@ -123,7 +121,7 @@ pyinstaller-hooks-contrib==2021.1
# via pyinstaller # via pyinstaller
pyinstaller==4.3 pyinstaller==4.3
# via -r requirements/dev.in # via -r requirements/dev.in
pylint==2.8.2 pylint==2.8.3
# via -r requirements/dev.in # via -r requirements/dev.in
pyparsing==2.4.7 pyparsing==2.4.7
# via packaging # via packaging
@ -169,29 +167,24 @@ six==1.16.0
# kubernetes # kubernetes
# python-dateutil # python-dateutil
# readme-renderer # readme-renderer
# websocket-client
toml==0.10.2 toml==0.10.2
# via # via
# black # black
# pep517 # pep517
# pylint # pylint
tqdm==4.60.0 tqdm==4.61.0
# via twine # via twine
twine==3.4.1 twine==3.4.1
# via -r requirements/dev.in # via -r requirements/dev.in
typed-ast==1.4.3 typed-ast==1.4.3
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# astroid
# black
# mypy # mypy
typing-extensions==3.10.0.0 typing-extensions==3.10.0.0
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# black
# importlib-metadata
# mypy # mypy
urllib3==1.25.11 urllib3==1.26.5
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# kubernetes # kubernetes
@ -202,16 +195,14 @@ wcwidth==0.2.5
# prompt-toolkit # prompt-toolkit
webencodings==0.5.1 webencodings==0.5.1
# via bleach # via bleach
websocket-client==0.59.0 websocket-client==1.0.1
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# kubernetes # kubernetes
wrapt==1.12.1 wrapt==1.12.1
# via astroid # via astroid
zipp==3.4.1 zipp==3.4.1
# via # via importlib-metadata
# importlib-metadata
# pep517
# The following packages are considered to be unsafe in a requirements file: # The following packages are considered to be unsafe in a requirements file:
# pip # pip

View File

@ -14,7 +14,7 @@ cachetools==4.2.2
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# google-auth # google-auth
certifi==2020.12.5 certifi==2021.5.30
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# kubernetes # kubernetes
@ -23,9 +23,9 @@ chardet==4.0.0
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# requests # requests
click-repl==0.1.6 click-repl==0.2.0
# via -r requirements/base.txt # via -r requirements/base.txt
click==7.1.2 click==8.0.1
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# click-repl # click-repl
@ -33,7 +33,7 @@ docutils==0.16
# via # via
# sphinx # sphinx
# sphinx-rtd-theme # sphinx-rtd-theme
google-auth==1.30.0 google-auth==1.30.1
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# kubernetes # kubernetes
@ -43,24 +43,23 @@ idna==2.10
# requests # requests
imagesize==1.2.0 imagesize==1.2.0
# via sphinx # via sphinx
jinja2==2.11.3 jinja2==3.0.1
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# sphinx # sphinx
kubernetes==12.0.1 kubernetes==17.17.0
# via -r requirements/base.txt # via -r requirements/base.txt
markupsafe==1.1.1 markupsafe==2.0.1
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# jinja2 # jinja2
# sphinx
mypy-extensions==0.4.3 mypy-extensions==0.4.3
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# mypy # mypy
mypy==0.812 mypy==0.812
# via -r requirements/base.txt # via -r requirements/base.txt
oauthlib==3.1.0 oauthlib==3.1.1
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# requests-oauthlib # requests-oauthlib
@ -116,12 +115,11 @@ six==1.16.0
# google-auth # google-auth
# kubernetes # kubernetes
# python-dateutil # python-dateutil
# websocket-client
snowballstemmer==2.1.0 snowballstemmer==2.1.0
# via sphinx # via sphinx
sphinx-rtd-theme==0.5.2 sphinx-rtd-theme==0.5.2
# via -r requirements/docs.in # via -r requirements/docs.in
sphinx==4.0.1 sphinx==4.0.2
# via # via
# -r requirements/docs.in # -r requirements/docs.in
# sphinx-rtd-theme # sphinx-rtd-theme
@ -129,13 +127,13 @@ sphinxcontrib-applehelp==1.0.2
# via sphinx # via sphinx
sphinxcontrib-devhelp==1.0.2 sphinxcontrib-devhelp==1.0.2
# via sphinx # via sphinx
sphinxcontrib-htmlhelp==1.0.3 sphinxcontrib-htmlhelp==2.0.0
# via sphinx # via sphinx
sphinxcontrib-jsmath==1.0.1 sphinxcontrib-jsmath==1.0.1
# via sphinx # via sphinx
sphinxcontrib-qthelp==1.0.3 sphinxcontrib-qthelp==1.0.3
# via sphinx # via sphinx
sphinxcontrib-serializinghtml==1.1.4 sphinxcontrib-serializinghtml==1.1.5
# via sphinx # via sphinx
typed-ast==1.4.3 typed-ast==1.4.3
# via # via
@ -145,7 +143,7 @@ typing-extensions==3.10.0.0
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# mypy # mypy
urllib3==1.25.11 urllib3==1.26.5
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# kubernetes # kubernetes
@ -154,7 +152,7 @@ wcwidth==0.2.5
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# prompt-toolkit # prompt-toolkit
websocket-client==0.59.0 websocket-client==1.0.1
# via # via
# -r requirements/base.txt # -r requirements/base.txt
# kubernetes # kubernetes

View File

@ -20,7 +20,7 @@ class EnvTests(unittest.TestCase):
template_name = "apps/openedx/settings/partials/common_all.py" template_name = "apps/openedx/settings/partials/common_all.py"
renderer = env.Renderer({}, [env.TEMPLATES_ROOT], ignore_folders=["partials"]) renderer = env.Renderer({}, [env.TEMPLATES_ROOT], ignore_folders=["partials"])
templates = list(renderer.walk_templates("apps")) templates = list(renderer.walk_templates("apps"))
self.assertIn(template_name, renderer.environment.loader.list_templates()) # type: ignore self.assertIn(template_name, renderer.environment.loader.list_templates())
self.assertNotIn(template_name, templates) self.assertNotIn(template_name, templates)
def test_is_binary_file(self) -> None: def test_is_binary_file(self) -> None:
@ -174,5 +174,5 @@ class EnvTests(unittest.TestCase):
config["PLUGINS"] = ["myplugin"] config["PLUGINS"] = ["myplugin"]
env2 = env.Renderer.instance(config).environment env2 = env.Renderer.instance(config).environment
self.assertNotIn("plugin1/myplugin.txt", env1.loader.list_templates()) # type: ignore self.assertNotIn("plugin1/myplugin.txt", env1.loader.list_templates())
self.assertIn("plugin1/myplugin.txt", env2.loader.list_templates()) # type: ignore self.assertIn("plugin1/myplugin.txt", env2.loader.list_templates())

View File

@ -15,6 +15,14 @@ VERSION_FILENAME = "version"
BIN_FILE_EXTENSIONS = [".ico", ".jpg", ".png", ".ttf", ".woff", ".woff2"] BIN_FILE_EXTENSIONS = [".ico", ".jpg", ".png", ".ttf", ".woff", ".woff2"]
class JinjaEnvironment(jinja2.Environment):
loader: jinja2.BaseLoader
def __init__(self, template_roots: List[str]) -> None:
loader = jinja2.FileSystemLoader(template_roots)
super().__init__(loader=loader, undefined=jinja2.StrictUndefined)
class Renderer: class Renderer:
@classmethod @classmethod
def instance(cls: Type["Renderer"], config: Config) -> "Renderer": def instance(cls: Type["Renderer"], config: Config) -> "Renderer":
@ -39,10 +47,7 @@ class Renderer:
self.ignore_folders.append(".git") self.ignore_folders.append(".git")
# Create environment # Create environment
environment = jinja2.Environment( environment = JinjaEnvironment(template_roots)
loader=jinja2.FileSystemLoader(template_roots),
undefined=jinja2.StrictUndefined,
)
environment.filters["common_domain"] = utils.common_domain environment.filters["common_domain"] = utils.common_domain
environment.filters["encrypt"] = utils.encrypt environment.filters["encrypt"] = utils.encrypt
environment.filters["list_if"] = utils.list_if environment.filters["list_if"] = utils.list_if
@ -61,9 +66,7 @@ class Renderer:
The elements of `prefix` must contain only "/", and not os.sep. The elements of `prefix` must contain only "/", and not os.sep.
""" """
full_prefix = "/".join(prefix) full_prefix = "/".join(prefix)
env_templates: List[ env_templates: List[str] = self.environment.loader.list_templates()
str
] = self.environment.loader.list_templates() # type:ignore[no-untyped-call]
for template in env_templates: for template in env_templates:
if template.startswith(full_prefix) and self.is_part_of_env(template): if template.startswith(full_prefix) and self.is_part_of_env(template):
yield template yield template