Skip to content

Commit

Permalink
Code style gardening by black
Browse files Browse the repository at this point in the history
re: black updated from v19.10b0 to v20.8b1
  • Loading branch information
douglatornell committed Nov 10, 2020
1 parent 292892c commit e5f065a
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 76 deletions.
3 changes: 1 addition & 2 deletions salishsea_site/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@


def main(global_config, **settings):
"""Configure the Pyramid WSGI application.
"""
"""Configure the Pyramid WSGI application."""
config = Configurator(settings=settings)
_static_views(config, settings)
_copyright_year_range(config)
Expand Down
15 changes: 5 additions & 10 deletions salishsea_site/views/fvcom.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@

@view_config(route_name="fvcom.results.index", renderer="fvcom/results_index.mako")
def results_index(request):
"""Render results calendar grid index page.
"""
"""Render results calendar grid index page."""
INDEX_GRID_COLS = 21
# Calculate the date range to display in the grid and the number of
# columns for the month headings of the grid
Expand Down Expand Up @@ -261,17 +260,15 @@ def _exclude_missing_dates(dates, figures, run_type):
# Legacy route
@view_config(route_name="fvcom.results.nowcast.publish", renderer="fvcom/publish.mako")
def nowcast_x2_publish(request):
"""Render nowcast figures page.
"""
"""Render nowcast figures page."""
return _values_for_publish_template(request, "nowcast-x2")


@view_config(
route_name="fvcom.results.nowcast-r12.publish", renderer="fvcom/publish.mako"
)
def nowcast_r12_publish(request):
"""Render nowcast figures page.
"""
"""Render nowcast figures page."""
return _values_for_publish_template(request, "nowcast-r12")


Expand All @@ -281,14 +278,12 @@ def nowcast_r12_publish(request):
# Legacy route
@view_config(route_name="fvcom.results.forecast.publish", renderer="fvcom/publish.mako")
def forecast_x2_publish(request):
"""Render forecast figures page.
"""
"""Render forecast figures page."""
return _values_for_publish_template(request, "forecast-x2")


def _values_for_publish_template(request, run_type):
"""Calculate template variable values for a figures page.
"""
"""Calculate template variable values for a figures page."""
results_date = arrow.get(request.matchdict["results_date"], "DDMMMYY")
available_figures = {
"water levels": tide_stn_water_level_figure_group.available(
Expand Down
33 changes: 11 additions & 22 deletions salishsea_site/views/salishseacast.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,7 @@
# Legacy route
@view_config(route_name="storm_surge.index.html", renderer="storm_surge/portal.mako")
def storm_surge_portal(request):
"""Render storm surge portal page.
"""
"""Render storm surge portal page."""
return {}


Expand Down Expand Up @@ -430,8 +429,7 @@ def storm_surge_forecast(request):

@view_config(route_name="storm_surge.alert.feed", renderer="string")
def storm_surge_alert_feed(request):
"""Render the requested storm surge alert ATOM feed file.
"""
"""Render the requested storm surge alert ATOM feed file."""
introspector = request.registry.introspector
figs_server = request.registry.settings["nowcast_figures_server_name"]
figs_path = introspector.get("static views", figs_server)["spec"]
Expand All @@ -457,8 +455,7 @@ def about(request):
route_name="results.index.html", renderer="salishseacast/results_index.mako"
)
def results_index(request):
"""Render results calendar grid index page.
"""
"""Render results calendar grid index page."""
INDEX_GRID_COLS = 21
# Calculate the date range to display in the grid and the number of
# columns for the month headings of the grid
Expand Down Expand Up @@ -550,8 +547,7 @@ def _exclude_missing_dates(dates, figures, figs_type, run_type, model):
route_name="results.forecast.publish.html", renderer="salishseacast/publish.mako"
)
def forecast_publish(request):
"""Render storm surge forecast figures page.
"""
"""Render storm surge forecast figures page."""
results_date = arrow.get(request.matchdict["results_date"], "DDMMMYY")
run_date = results_date.shift(days=-1)
return _data_for_publish_template(
Expand All @@ -572,8 +568,7 @@ def forecast_publish(request):
route_name="results.forecast2.publish.html", renderer="salishseacast/publish.mako"
)
def forecast2_publish(request):
"""Render preliminary storm surge forecast figures page.
"""
"""Render preliminary storm surge forecast figures page."""
results_date = arrow.get(request.matchdict["results_date"], "DDMMMYY")
run_date = results_date.shift(days=-2)
return _data_for_publish_template(
Expand All @@ -591,8 +586,7 @@ def forecast2_publish(request):
renderer="salishseacast/surface_currents.mako",
)
def forecast_surface_currents(request):
"""Render surface currents tiles forecast figures page.
"""
"""Render surface currents tiles forecast figures page."""
results_date = arrow.get(request.matchdict["results_date"], "DDMMMYY")
run_date = results_date.shift(days=-1)
tile_dates = list(
Expand All @@ -616,8 +610,7 @@ def forecast_surface_currents(request):
renderer="salishseacast/surface_currents.mako",
)
def forecast2_surface_currents(request):
"""Render surface currents tiles forecast2 figures page.
"""
"""Render surface currents tiles forecast2 figures page."""
results_date = arrow.get(request.matchdict["results_date"], "DDMMMYY")
run_date = results_date.shift(days=-2)
tile_dates = list(arrow.Arrow.range("day", run_date, run_date.shift(days=+3)))
Expand All @@ -639,8 +632,7 @@ def forecast2_surface_currents(request):
renderer="salishseacast/surface_currents.mako",
)
def nowcast_green_surface_currents(request):
"""Render surface currents tiles nowcast-green figures page.
"""
"""Render surface currents tiles nowcast-green figures page."""
results_date = arrow.get(request.matchdict["results_date"], "DDMMMYY")
run_date = results_date
tile_dates = list(arrow.Arrow.range("day", run_date, run_date.shift(days=+3)))
Expand Down Expand Up @@ -737,8 +729,7 @@ def nowcast_currents_physics(request):
route_name="results.nowcast.biology", renderer="salishseacast/biology.mako"
)
def nowcast_biology(request):
"""Render model research biology evaluation results figures page.
"""
"""Render model research biology evaluation results figures page."""
results_date = arrow.get(request.matchdict["results_date"], "DDMMMYY")
available_figures = {
"baynes sound": [
Expand Down Expand Up @@ -776,8 +767,7 @@ def nowcast_biology(request):
route_name="results.nowcast.timeseries", renderer="salishseacast/timeseries.mako"
)
def nowcast_timeseries(request):
"""Render model research timeseries evaluation results figures page.
"""
"""Render model research timeseries evaluation results figures page."""
results_date = arrow.get(request.matchdict["results_date"], "DDMMMYY")
available_figures = timeseries_figure_group.available("nowcast-green", results_date)
if not any(available_figures):
Expand All @@ -800,8 +790,7 @@ def nowcast_timeseries(request):
renderer="salishseacast/comparison.mako",
)
def nowcast_comparison(request):
"""Render model and observation comparisons figures page.
"""
"""Render model and observation comparisons figures page."""
results_date = arrow.get(request.matchdict["results_date"], "DDMMMYY")
ungrouped_figures = [
fig for fig in comparison_figures if fig.available("nowcast", results_date)
Expand Down
6 changes: 2 additions & 4 deletions salishsea_site/views/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@
@view_config(route_name="site.index", renderer="index.mako")
@view_config(route_name="site.index.html", renderer="index.mako")
def index(request):
"""Render site index page.
"""
"""Render site index page."""
return {}


@view_config(route_name="robots.txt", renderer="robots.mako")
def robots(request):
"""Render robots.txt page.
"""
"""Render robots.txt page."""
return {}
9 changes: 3 additions & 6 deletions salishsea_site/views/wwatch3.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@

@view_config(route_name="wwatch3.results.index", renderer="wwatch3/results_index.mako")
def results_index(request):
"""Render results calendar grid index page.
"""
"""Render results calendar grid index page."""
INDEX_GRID_COLS = 21
# Calculate the date range to display in the grid and the number of
# columns for the month headings of the grid
Expand Down Expand Up @@ -93,8 +92,7 @@ def _exclude_missing_dates(dates, figures, figs_type, run_type):
route_name="wwatch3.results.forecast.publish", renderer="wwatch3/publish.mako"
)
def forecast_publish(request):
"""Render forecast figures page.
"""
"""Render forecast figures page."""
results_date = arrow.get(request.matchdict["results_date"], "DDMMMYY")
figures_available = wave_height_period_figure_group.available(
"forecast", results_date, "wwatch3"
Expand All @@ -115,8 +113,7 @@ def forecast_publish(request):
route_name="wwatch3.results.forecast2.publish", renderer="wwatch3/publish.mako"
)
def forecast2_publish(request):
"""Render forecast2 figures page.
"""
"""Render forecast2 figures page."""
results_date = arrow.get(request.matchdict["results_date"], "DDMMMYY")
figures_available = wave_height_period_figure_group.available(
"forecast2", results_date, "wwatch3"
Expand Down
6 changes: 2 additions & 4 deletions tests/views/test_bloomcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@


class TestAbout:
"""Unit tests for bloomcast about view.
"""
"""Unit tests for bloomcast about view."""

def test_about(self):
request = get_current_request()
Expand All @@ -37,8 +36,7 @@ def test_about(self):

@patch("salishsea_site.views.bloomcast.Path", spec=Path)
class TestSpringDiatoms:
"""Unit tests for bloomcast sprint_diatoms view.
"""
"""Unit tests for bloomcast sprint_diatoms view."""

def test_spring_diatoms(self, m_path):
m_path().__truediv__().open().__enter__.side_effect = (
Expand Down
3 changes: 1 addition & 2 deletions tests/views/test_figures.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@


class TestImageLoop:
"""Unit tests for ImageLoop class.
"""
"""Unit tests for ImageLoop class."""

def test_first_available(self):
img_loop = salishsea_site.views.figures.ImageLoop(
Expand Down
39 changes: 13 additions & 26 deletions tests/views/test_salishseacast.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@


class TestStormSurgePortal:
"""Unit tests for storm_surge_portal view.
"""
"""Unit tests for storm_surge_portal view."""

def test_storm_surge_portal(self):
request = get_current_request()
Expand All @@ -41,8 +40,7 @@ def test_storm_surge_portal(self):
@pytest.mark.usefixtures("pconfig")
@patch("salishsea_site.views.salishseacast._data_for_publish_template")
class TestStormSurgeForecast:
"""Unit tests for storm_surge_forecast view.
"""
"""Unit tests for storm_surge_forecast view."""

def test_no_forecast(self, m_dfpt):
m_dfpt.side_effect = HTTPNotFound
Expand Down Expand Up @@ -107,8 +105,7 @@ def test_previous_forecast(self, m_dfpt):
@pytest.mark.usefixtures("pconfig")
@patch("salishsea_site.views.salishseacast.logger")
class TestStormSurgeAlertFeed:
"""Unit tests for storm_surge_alert_feed view.
"""
"""Unit tests for storm_surge_alert_feed view."""

def test_feed_file_not_found(self, m_logger, pconfig):
pconfig.add_settings(nowcast_figures_server_name="nowcast-sys/figures/")
Expand Down Expand Up @@ -138,8 +135,7 @@ def test_render_feed_file(self, m_path, m_logger, pconfig):


class TestAboutSalishSeaCast:
"""Unit tests for SalishSeaCast about view.
"""
"""Unit tests for SalishSeaCast about view."""

def test_about(self):
request = get_current_request()
Expand All @@ -150,8 +146,7 @@ def test_about(self):
@pytest.mark.usefixtures("pconfig")
@patch("salishsea_site.views.salishseacast.FigureMetadata.available")
class TestResultsIndex:
"""Unit tests for results_index view.
"""
"""Unit tests for results_index view."""

def test_first_date(self, m_available):
m_available.return_value = True
Expand Down Expand Up @@ -258,8 +253,7 @@ def test_exclude_missing_dates_calls(
@pytest.mark.usefixtures("pconfig")
@patch("salishsea_site.views.salishseacast._data_for_publish_template")
class TestForecastPublish:
"""Unit test for forecast_publish view view.
"""
"""Unit test for forecast_publish view view."""

def test_forecast_publish(self, m_dfpt):
request = get_current_request()
Expand All @@ -278,8 +272,7 @@ def test_forecast_publish(self, m_dfpt):
@pytest.mark.usefixtures("pconfig")
@patch("salishsea_site.views.salishseacast._data_for_publish_template")
class TestForecast2Publish:
"""Unit test for forecast2_publish view view.
"""
"""Unit test for forecast2_publish view view."""

def test_forecast2_publish(self, m_dfpt):
request = get_current_request()
Expand All @@ -298,8 +291,7 @@ def test_forecast2_publish(self, m_dfpt):
@pytest.mark.usefixtures("pconfig")
@patch("salishsea_site.views.salishseacast.FigureMetadata.available")
class TestCurrentsPhysics:
"""Unit tests for nowcast_currents_physics view.
"""
"""Unit tests for nowcast_currents_physics view."""

def test_no_figures_raises_httpnotfound(self, m_available):
request = get_current_request()
Expand Down Expand Up @@ -339,8 +331,7 @@ def test_figures(self, m_available):
@pytest.mark.usefixtures("pconfig")
@patch("salishsea_site.views.salishseacast.ImageLoop.available")
class TestBiology:
"""Unit tests for nowcast_biology view.
"""
"""Unit tests for nowcast_biology view."""

def test_no_figures_raises_httpnotfound(self, m_available):
request = get_current_request()
Expand Down Expand Up @@ -380,8 +371,7 @@ def test_image_loop(self, m_available):
@pytest.mark.usefixtures("pconfig")
@patch("salishsea_site.views.salishseacast.FigureGroup.available")
class TestTimeseries:
"""Unit tests for nowcast_timeseries view.
"""
"""Unit tests for nowcast_timeseries view."""

def test_no_figures_raises_httpnotfound(self, m_available):
request = get_current_request()
Expand Down Expand Up @@ -421,8 +411,7 @@ def test_figures(self, m_available):
@pytest.mark.usefixtures("pconfig")
@patch("salishsea_site.views.salishseacast.FigureMetadata.available")
class TestNowcastComparison:
"""Unit tests for nowcast_comparison view.
"""
"""Unit tests for nowcast_comparison view."""

def test_no_figures_raises_httpnotfound(self, m_available):
request = get_current_request()
Expand Down Expand Up @@ -479,8 +468,7 @@ def test_onc_venus_figures(self, m_available):
@pytest.mark.usefixtures("pconfig")
@patch("salishsea_site.views.salishseacast.FigureMetadata.available")
class TestDataForPublishTemplate:
"""Unit test for _data_for_publish_template view utility function.
"""
"""Unit test for _data_for_publish_template view utility function."""

def test_no_alerts_fig_raises_httpnotfound(self, m_available):
request = get_current_request()
Expand Down Expand Up @@ -585,8 +573,7 @@ def test_missing_figures(self, m_available):
@pytest.mark.usefixtures("pconfig")
@patch("salishsea_site.views.salishseacast.logger")
class TestNowcastLogs:
"""Unit tests for nowcast_logs view.
"""
"""Unit tests for nowcast_logs view."""

def test_envvar_not_set(self, m_logger):
request = get_current_request()
Expand Down

0 comments on commit e5f065a

Please sign in to comment.