Skip to content
Open
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
4 changes: 2 additions & 2 deletions dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Use with `python -i dev.py` for a useful interactive shell.
"""

import yaml
from ruamel import yaml

from routemaster.db import * # noqa: F403, F401
from routemaster.app import App
Expand All @@ -18,7 +18,7 @@ def app_from_config(config_path):
By default, will use the example.yaml file.
"""
with open(config_path, 'r') as f:
config = load_config(yaml.load(f))
config = load_config(yaml.safe_load(f))

class InteractiveApp(App):
"""
Expand Down
4 changes: 2 additions & 2 deletions routemaster/cli.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""CLI handling for `routemaster`."""
import logging

import yaml
import click
from ruamel import yaml

from routemaster.app import App
from routemaster.cron import CronThread
Expand All @@ -29,7 +29,7 @@ def main(ctx, config_file):
logging.getLogger('schedule').setLevel(logging.CRITICAL)

try:
config = load_config(yaml.load(config_file))
config = load_config(yaml.safe_load(config_file))
except ConfigError:
logger.exception("Configuration Error")
click.get_current_context().exit(1)
Expand Down
4 changes: 2 additions & 2 deletions routemaster/config/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import datetime
from typing import Any, Dict, List, Optional

import yaml
import jsonschema
import pkg_resources
import jsonschema.exceptions
from ruamel import yaml

from routemaster.config.model import (
Gate,
Expand Down Expand Up @@ -71,7 +71,7 @@ def _schema_validate(config: Yaml) -> None:
'routemaster.config',
'schema.yaml',
).decode('utf-8')
schema_yaml = yaml.load(schema_raw)
schema_yaml = yaml.safe_load(schema_raw)

try:
jsonschema.validate(config, schema_yaml)
Expand Down
6 changes: 3 additions & 3 deletions routemaster/config/tests/test_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pathlib import Path
from unittest import mock

import yaml
from ruamel import yaml
import pytest

from routemaster.config import (
Expand Down Expand Up @@ -37,7 +37,7 @@ def reset_environment():

def yaml_data(name: str):
with open(f'test_data/{name}.yaml') as f:
return yaml.load(f)
return yaml.safe_load(f)


@contextlib.contextmanager
Expand Down Expand Up @@ -372,7 +372,7 @@ def test_example_config_loads():

assert example_yaml.exists(), "Example file is missing! (is this test set up correctly?)"

example_config = load_config(yaml.load(example_yaml.read_text()))
example_config = load_config(yaml.safe_load(example_yaml.read_text()))

# Some basic assertions that we got the right thing loaded
assert list(example_config.state_machines.keys()) == ['user_lifecycle']
Expand Down
4 changes: 2 additions & 2 deletions routemaster/tests/test_validation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pathlib import Path

import yaml
from ruamel import yaml
import pytest

from routemaster.config import (
Expand Down Expand Up @@ -216,7 +216,7 @@ def test_example_config_is_valid(app):

assert example_yaml.exists(), "Example file is missing! (is this test set up correctly?)"

example_config = load_config(yaml.load(example_yaml.read_text()))
example_config = load_config(yaml.safe_load(example_yaml.read_text()))

# quick check that we've loaded the config we expect
assert list(example_config.state_machines.keys()) == ['user_lifecycle']
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

install_requires=(
'click',
'pyyaml',
'ruamel.yaml',
'jsonschema >=2.6',
'flask',
'psycopg2',
Expand Down