Skip to content
This repository was archived by the owner on Jun 3, 2023. It is now read-only.

Commit 85d2107

Browse files
Bump flask from 1.1.1 to 2.2.5 (#1)
* Bump flask from 1.1.1 to 2.2.5 Bumps [flask](https://github.com/pallets/flask) from 1.1.1 to 2.2.5. - [Release notes](https://github.com/pallets/flask/releases) - [Changelog](https://github.com/pallets/flask/blob/main/CHANGES.rst) - [Commits](pallets/flask@1.1.1...2.2.5) --- updated-dependencies: - dependency-name: flask dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Bump all dependencies and fix linters --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Fionn Fitzmaurice <fionn@github.com>
1 parent 71ab51b commit 85d2107

File tree

8 files changed

+68
-47
lines changed

8 files changed

+68
-47
lines changed

‎.github/workflows/main.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,30 @@ name: CI
33
on: push
44

55
jobs:
6+
67
lint:
8+
79
name: Lint
810
runs-on: ubuntu-latest
11+
912
steps:
10-
- uses: actions/checkout@v2
13+
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
1117
- name: Set up Python
12-
uses: actions/setup-python@v1
18+
uses: actions/setup-python@v4
1319
with:
14-
python-version: 3.8
20+
python-version: "3.10"
21+
1522
- name: Install dependencies
16-
run: |
17-
python -m pip install --upgrade pip
18-
pip install -r requirements.txt
19-
pip install -r requirements_dev.txt
20-
pip install safety
23+
run: pip install -r requirements.txt -r requirements_dev.txt
24+
env:
25+
PIP_DISABLE_PIP_VERSION_CHECK: 1
26+
PIP_PROGRESS_BAR: "off"
27+
2128
- name: Lint
2229
run: make lint
30+
2331
- name: Typecheck
2432
run: make typecheck
25-
- name: Safety check
26-
env:
27-
SAFETY_API_KEY: ${{ secrets.SAFETY_API_KEY }}
28-
run: safety check

‎mypy.ini renamed to ‎.mypy.ini

File renamed without changes.

‎app/server_admin/dns.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
import os
55
from dataclasses import dataclass
6-
from ipaddress import ip_address, IPv4Address
7-
from typing import Set, List, NamedTuple, Optional
6+
from ipaddress import IPv4Address
7+
from typing import NamedTuple, Optional
88

99
import boto3
1010

11-
NameDomain = NamedTuple("NameSubdomain", [("name", str), ("subdomain", str)])
12-
Infrastructure = NamedTuple("Infrastructure", [("clusters", List["Cluster"]),
13-
("servers", List["Server"])])
11+
NameDomain = NamedTuple("NameDomain", [("name", str), ("subdomain", str)])
12+
Infrastructure = NamedTuple("Infrastructure", [("clusters", list["Cluster"]),
13+
("servers", list["Server"])])
1414

1515
CLUSTER_MAP = {1: NameDomain("Los Angeles", "la"),
1616
2: NameDomain("New York", "nyc"),
@@ -57,7 +57,7 @@ class Cluster:
5757
def __init__(self, cluster_id: int, subdomain: str) -> None:
5858
self.cluster_id = cluster_id
5959
self.subdomain = subdomain
60-
self.server_instances: List[Server] = []
60+
self.server_instances: list[Server] = []
6161

6262
@property
6363
def cluster_name(self) -> str:
@@ -92,7 +92,7 @@ def _get_hosted_zone(self) -> dict:
9292
raise RuntimeError(f"Failed to find hosted zone for {self.name}")
9393

9494
@property
95-
def records(self) -> List[dict]:
95+
def records(self) -> list[dict]:
9696
"""Flexible record property"""
9797
record_sets = self.r53 \
9898
.list_resource_record_sets(HostedZoneId=self.id) \
@@ -101,17 +101,17 @@ def records(self) -> List[dict]:
101101
if (r["Type"] == "A" and r["Name"] != self.name)]
102102

103103
@staticmethod
104-
def ips_from_record(record: dict) -> Set[IPv4Address]:
104+
def ips_from_record(record: dict) -> set[IPv4Address]:
105105
"""Helper to get IP addresses from a given record"""
106106
ips = set()
107107
for value in record["ResourceRecords"]:
108-
ips.add(ip_address(value["Value"]))
108+
ips.add(IPv4Address(value["Value"]))
109109
return ips
110110

111-
def _a_record(self, name: str, ips: Set[IPv4Address],
111+
def _a_record(self, name: str, ips: set[IPv4Address],
112112
action: str, ttl: int = 30) -> None:
113113
change_batch = {
114-
"Comment": "add {} -> {}"
114+
"Comment": "add f{} -> {}" # pylint: disable=consider-using-f-string
115115
.format(name, ", ".join([ip.exploded for ip in ips])),
116116
"Changes": [
117117
{
@@ -134,7 +134,7 @@ def add_server(self, server: Server) -> None:
134134
"""Adds the server's IP to the cluster's subdomain."""
135135
fqdn = CLUSTER_MAP[server.cluster_id].subdomain + "." + self.name
136136

137-
ips: Set[IPv4Address] = set()
137+
ips: set[IPv4Address] = set()
138138
for record in self.records:
139139
if fqdn == record["Name"]:
140140
ips = self.ips_from_record(record)
@@ -149,7 +149,7 @@ def remove_server(self, server: Server) -> None:
149149
"""Removes the server's IP from the DNS record."""
150150
fqdn = CLUSTER_MAP[server.cluster_id].subdomain + "." + self.name
151151

152-
ips: Set[IPv4Address] = set()
152+
ips: set[IPv4Address] = set()
153153
for record in self.records:
154154
if fqdn == record["Name"]:
155155
ips = self.ips_from_record(record)
@@ -174,15 +174,15 @@ def create_infrastructure() -> Infrastructure:
174174
for cluster_id, ident in CLUSTER_MAP.items():
175175
clusters.append(Cluster(cluster_id, ident.subdomain))
176176

177-
clusters[0].create_server(1, ip=ip_address("2.4.6.8"))
178-
clusters[1].create_server(2, ip=ip_address("1.0.1.1"))
179-
clusters[2].create_server(3, ip=ip_address("5.6.7.8"))
180-
clusters[3].create_server(4, ip=ip_address("4.3.2.1"))
181-
clusters[3].create_server(5, ip=ip_address("1.2.3.4"))
182-
clusters[3].create_server(6, ip=ip_address("1.2.3.5"))
183-
clusters[3].create_server(7, ip=ip_address("1.2.3.6"))
184-
clusters[4].create_server(8, ip=ip_address("8.1.1.1"))
185-
clusters[5].create_server(9, ip=ip_address("9.1.1.1"))
177+
clusters[0].create_server(1, ip=IPv4Address("2.4.6.8"))
178+
clusters[1].create_server(2, ip=IPv4Address("1.0.1.1"))
179+
clusters[2].create_server(3, ip=IPv4Address("5.6.7.8"))
180+
clusters[3].create_server(4, ip=IPv4Address("4.3.2.1"))
181+
clusters[3].create_server(5, ip=IPv4Address("1.2.3.4"))
182+
clusters[3].create_server(6, ip=IPv4Address("1.2.3.5"))
183+
clusters[3].create_server(7, ip=IPv4Address("1.2.3.6"))
184+
clusters[4].create_server(8, ip=IPv4Address("8.1.1.1"))
185+
clusters[5].create_server(9, ip=IPv4Address("9.1.1.1"))
186186

187187
servers = []
188188
for cluster in clusters:
@@ -193,15 +193,15 @@ def create_infrastructure() -> Infrastructure:
193193

194194
return Infrastructure(clusters, servers)
195195

196-
def print_servers(server_instances: List[Server]) -> None:
196+
def print_servers(server_instances: list[Server]) -> None:
197197
"""ASCII analogy of the server UI"""
198198
print("\n\033[1mID\t Name\t Cluster\t IP\t\t DNS\033[0m")
199199
for server in server_instances:
200200
print(server.server_id, "\t", server.name, "\t",
201201
CLUSTER_MAP[server.cluster_id].name, "\t",
202202
server.ip_address, server.dns)
203203

204-
def print_dns(dns_records: List[dict], server_instances: List[Server]) -> None:
204+
def print_dns(dns_records: list[dict], server_instances: list[Server]) -> None:
205205
"""ASCII analogy of the DNS UI"""
206206
print("\n\033[1mDomain\t\t\t\t\t IP(s)\t\t Server(s)\t Cluster\033[0m")
207207
for record in dns_records:
@@ -214,7 +214,7 @@ def print_dns(dns_records: List[dict], server_instances: List[Server]) -> None:
214214
[CLUSTER_MAP[server.cluster_id].name
215215
for server in matching_servers])
216216

217-
def update_servers(records: List[dict], servers: List[Server]) -> None:
217+
def update_servers(records: list[dict], servers: list[Server]) -> None:
218218
"""Assigns to each server instance their DNS record name"""
219219
for server in servers:
220220
server.dns = None

‎app/tests/tests.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env python3
2+
3+
import unittest
4+
5+
from app import create_app
6+
7+
class BasicTest(unittest.TestCase):
8+
9+
def setUp(self) -> None:
10+
self.app = create_app()
11+
12+
def main() -> None:
13+
"""Entry point"""
14+
unittest.main(verbosity=2)
15+
16+
if __name__ == "__main__":
17+
main()

‎app/views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
@APP.route("/")
1919
@APP.route("/index")
20-
def index() -> flask.signals.template_rendered:
20+
def index() -> str:
2121
"""index"""
2222
links = [
2323
{
@@ -32,14 +32,14 @@ def index() -> flask.signals.template_rendered:
3232
return flask.render_template("index.html", title="Home", links=links)
3333

3434
@APP.route("/servers")
35-
def servers_ui() -> flask.signals.template_rendered:
35+
def servers_ui() -> str:
3636
"""Renders the server UI"""
3737
servers = INFRASTRUCTURE.servers
3838
dns.update_servers(ZONE.records, servers)
3939
return flask.render_template("servers.html", title="Servers", servers=servers)
4040

4141
@APP.route("/dns")
42-
def dns_ui() -> flask.signals.template_rendered:
42+
def dns_ui() -> str:
4343
"""Renders the DNS UI"""
4444
return flask.render_template("dns.html", title="DNS", zone_name=ZONE.name,
4545
servers=INFRASTRUCTURE.servers,

‎requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
flask == 1.1.1
2-
boto3 == 1.9.210
3-
gunicorn == 19.9.0
1+
flask == 2.3.2
2+
boto3 == 1.26.125
3+
gunicorn == 20.1.0

‎requirements_dev.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
mypy >= 0.720
2-
pylint >= 2.3.1
3-
python-dotenv >= 0.10.3
1+
mypy == 1.2.0
2+
pylint == 2.17.3
3+
python-dotenv == 1.0.0

‎runtime.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
python-3.8.1
1+
python-3.10.11

0 commit comments

Comments
 (0)