Skip to content

Commit 9efd6a6

Browse files
authoredMar 22, 2023
Merge pull request #221 from HackSoc/lm/2023-03-10_update-python-ver
Update supported python versions
2 parents 865328b + 1d15920 commit 9efd6a6

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed
 

‎.github/workflows/unittest.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
matrix:
1313
os: [ubuntu-latest, macOS-latest, windows-latest]
14-
py_ver: ["3.7", "3.8", "3.9"]
14+
py_ver: ["3.7", "3.8", "3.9", "3.10", "3.11"]
1515
fail-fast: false
1616
runs-on: ${{ matrix.os }}
1717
steps:

‎hacksoc_org/__init__.py

+9
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,21 @@
44
This module contains the Flask and Jinja boilerplate, HackSoc-specific customisations for pages,
55
and user convenience functionality for local testing.
66
"""
7+
import sys
8+
9+
if sys.version_info < (3, 7):
10+
print(
11+
"Warning: you are using an older version of Python ("
12+
+ str(sys.version)
13+
+ ") that is not supported by HackSoc.org."
14+
)
715

816

917
import flask
1018
import yaml
1119
from os import path
1220

21+
1322
# flask app is constructed here
1423
app = flask.Flask(__name__, static_folder=None, template_folder=None)
1524
# these folders are defined in the Blueprint anyway

‎hacksoc_org/freeze.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,7 @@ def get_redirect_page_routes() -> Generator[str, None, None]:
8484
Yields:
8585
Generator[str, None, None]: URL routes
8686
"""
87-
yield from [
88-
"/newsletter.html",
89-
"/slack.html",
90-
"/discord.html"
91-
]
87+
yield from ["/newsletter.html", "/slack.html", "/discord.html"]
9288

9389

9490
def freeze():

‎hacksoc_org/loaders.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def get_source(
5454
filename = os.path.join(self.path, removesuffix(template, ".html.jinja2") + ".md")
5555

5656
if os.path.exists(filename):
57-
with open(filename, encoding='utf-8') as fd:
57+
with open(filename, encoding="utf-8") as fd:
5858
metadata, markdown = frontmatter.parse(fd.read())
5959
assert isinstance(metadata, dict)
6060
source = """
@@ -74,8 +74,9 @@ def get_source(
7474
else:
7575
raise TemplateNotFound(filename)
7676

77+
7778
class MarkdownNewsLoader(BaseLoader):
78-
"""Finds news articles written in Markdown and wrangles them into a Jinja template
79+
"""Finds news articles written in Markdown and wrangles them into a Jinja template
7980
extending article.html.jinja2"""
8081

8182
def __init__(self, searchpath: str, prefix_allow: Optional[str] = None) -> None:
@@ -118,7 +119,7 @@ def get_source(
118119

119120
filename = os.path.join(self.searchpath, removesuffix(template, ".html.jinja2") + ".md")
120121
if os.path.exists(filename):
121-
with open(filename, encoding='utf-8') as fd:
122+
with open(filename, encoding="utf-8") as fd:
122123
metadata, content = frontmatter.parse(fd.read())
123124
# NB: readlines() returns a list of lines WITH \n at the end
124125

@@ -141,4 +142,4 @@ def get_source(
141142
return (source, filename, None)
142143
# TODO: add 3rd tuple argument for autoreloading
143144
else:
144-
raise TemplateNotFound(template)
145+
raise TemplateNotFound(template)

‎hacksoc_org/serve.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ def serve(basedir: str, port=5000):
1616
print(f"Serving {basedir} at http://127.0.0.1:{port}/ ...")
1717

1818
handler = functools.partial(http.server.SimpleHTTPRequestHandler, directory=basedir)
19-
server = http.server.HTTPServer(('localhost', port), RequestHandlerClass=handler)
19+
server = http.server.HTTPServer(("localhost", port), RequestHandlerClass=handler)
2020
server.serve_forever()

0 commit comments

Comments
 (0)
Please sign in to comment.