Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type (almost) all the things #122

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ references:
restore-build-dependency-cache: &restore-build-dependency-cache
restore_cache:
name: Restore build dependency cache
key: deps-venv-{{ .Branch }}-{{ .Environment.CIRCLE_STAGE }}-{{ checksum ".circleci/requirements.txt" }}
key: deps-venv-1-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum ".circleci/requirements.txt" }}

install-build-dependencies: &install-build-dependencies
run:
Expand All @@ -35,7 +35,7 @@ references:
save-build-dependency-cache: &save-build-dependency-cache
save_cache:
name: Save build dependency cache
key: deps-venv-{{ .Branch }}-{{ .Environment.CIRCLE_STAGE }}-{{ checksum ".circleci/requirements.txt" }}
key: deps-venv-1-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum ".circleci/requirements.txt" }}
paths:
- "venv"

Expand Down Expand Up @@ -70,15 +70,15 @@ references:
done
- restore_cache:
name: Restore .tox cache
key: deps-tox-{{ .Branch }}-{{ .Environment.CIRCLE_STAGE }}-{{ checksum ".checksum" }}
key: deps-tox-1-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum ".checksum" }}
- run:
name: Test
command: |
. venv/bin/activate
tox
- save_cache:
name: Save .tox cache
key: deps-tox-{{ .Branch }}-{{ .Environment.CIRCLE_STAGE }}-{{ checksum ".checksum" }}
key: deps-tox-1-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum ".checksum" }}
paths:
- ".tox"

Expand All @@ -99,7 +99,7 @@ jobs:
test-36:
<<: *test-template
docker:
- image: circleci/python:3.6
- image: cimg/python:3.6
environment:
<<: *steps-environment
TOXENV: py36
Expand All @@ -110,7 +110,7 @@ jobs:
test-37:
<<: *test-template
docker:
- image: circleci/python:3.7
- image: cimg/python:3.7
environment:
<<: *steps-environment
TOXENV: py37
Expand All @@ -121,7 +121,7 @@ jobs:
test-38:
<<: *test-template
docker:
- image: circleci/python:3.8
- image: cimg/python:3.8
environment:
<<: *steps-environment
TOXENV: py38
Expand All @@ -132,7 +132,7 @@ jobs:
test-39:
<<: *test-template
docker:
- image: circleci/python:3.9
- image: cimg/python:3.9
environment:
<<: *steps-environment
TOXENV: py39
Expand All @@ -143,7 +143,7 @@ jobs:
test-310:
<<: *test-template
docker:
- image: circleci/python:3.10
- image: cimg/python:3.10
environment:
<<: *steps-environment
TOXENV: py310
Expand All @@ -154,7 +154,7 @@ jobs:
lint:
working_directory: ~/routemaster
docker:
- image: circleci/python:3.6.3
- image: cimg/python:3.6
steps:
- checkout

Expand All @@ -164,15 +164,15 @@ jobs:

- restore_cache:
name: Restore .tox cache
key: deps-tox-{{ checksum "scripts/linting/requirements.txt" }}
key: deps-tox-1-{{ checksum "scripts/linting/requirements.txt" }}
- run:
name: Lint
command: |
. venv/bin/activate
TOXENV=lint tox
- save_cache:
name: Save .tox cache
key: deps-tox-{{ checksum "scripts/linting/requirements.txt" }}
key: deps-tox-1-{{ checksum "scripts/linting/requirements.txt" }}
paths:
- ".tox"
- store_test_results:
Expand All @@ -181,7 +181,7 @@ jobs:
typecheck:
working_directory: ~/routemaster
docker:
- image: circleci/python:3.6.3
- image: cimg/python:3.6
steps:
- checkout

Expand All @@ -191,15 +191,15 @@ jobs:

- restore_cache:
name: Restore .tox cache
key: deps-tox-{{ checksum "scripts/typechecking/requirements.txt" }}
key: deps-tox-1-{{ checksum "scripts/typechecking/requirements.txt" }}
- run:
name: Typecheck
command: |
. venv/bin/activate
TOXENV=mypy tox
- save_cache:
name: Save .tox cache
key: deps-tox-{{ checksum "scripts/typechecking/requirements.txt" }}
key: deps-tox-1-{{ checksum "scripts/typechecking/requirements.txt" }}
paths:
- ".tox"
- store_test_results:
Expand All @@ -208,7 +208,7 @@ jobs:
release:
working_directory: ~/routemaster
docker:
- image: circleci/python:3.6.3
- image: cimg/python:3.6
steps:
- checkout

Expand Down
8 changes: 4 additions & 4 deletions routemaster/app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Core App singleton that holds state for the application."""
import threading
import contextlib
from typing import Dict, Optional
from typing import Dict, Iterator, Optional

from sqlalchemy.orm import Session, sessionmaker
from sqlalchemy.engine import Engine
Expand Down Expand Up @@ -32,7 +32,7 @@ def __init__(
self.config = config
self.initialise()

def initialise(self):
def initialise(self) -> None:
"""
Initialise this instance of the app.

Expand Down Expand Up @@ -66,7 +66,7 @@ def session(self) -> Session:

return self._current_session

def set_rollback(self):
def set_rollback(self) -> None:
"""Mark the current session as needing rollback."""
if self._current_session is None:
raise RuntimeError(
Expand All @@ -77,7 +77,7 @@ def set_rollback(self):
self._needs_rollback = True

@contextlib.contextmanager
def new_session(self):
def new_session(self) -> Iterator[None]:
"""Run a single session in this scope."""
if self._current_session is not None:
raise RuntimeError("There is already a session running.")
Expand Down
2 changes: 1 addition & 1 deletion routemaster/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def post_fork():
cron_thread.stop()


def _validate_config(app: App):
def _validate_config(app: App) -> None:
try:
validate_config(app, app.config)
except ValidationError as e:
Expand Down
2 changes: 1 addition & 1 deletion routemaster/config/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from routemaster.exit_conditions import ExitConditionProgram

if TYPE_CHECKING:
from routemaster.context import Context # noqa
from routemaster.context import Context


class SystemTimeTrigger(NamedTuple):
Expand Down
Loading