Skip to content

Commit

Permalink
fix linting issues from black version update
Browse files Browse the repository at this point in the history
  • Loading branch information
struan committed Nov 20, 2024
1 parent e68ce6b commit 3bdc2a9
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 54 deletions.
1 change: 1 addition & 0 deletions caps/dataframe/la.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
local authority data
"""

from functools import lru_cache
from typing import Callable, Optional, List
import string
Expand Down
1 change: 0 additions & 1 deletion caps/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Forms for the CAPS app
"""


from django.forms import CharField, ChoiceField, ModelChoiceField, RadioSelect, Select
from haystack.forms import SearchForm
from haystack.inputs import Exact
Expand Down
1 change: 1 addition & 0 deletions caps/management/commands/import_emissions_data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Import local authority_emissions
"""

import pandas as pd
from caps.models import Council, DataPoint, DataType
from django.core.management.base import BaseCommand
Expand Down
1 change: 1 addition & 0 deletions caps/management/commands/import_polling_data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Import local authority_emissions
"""

import pandas as pd
from caps.models import Council, DataPoint, DataType
from django.core.management.base import BaseCommand
Expand Down
1 change: 1 addition & 0 deletions caps/search_funcs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Functions for use by the semantic search features
"""

import re
from collections import namedtuple
from itertools import groupby
Expand Down
24 changes: 12 additions & 12 deletions caps/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ def get_context_data(self, **kwargs):
)
context = add_context_for_plans_download_and_search(context)
context["page_title"] = "Local Climate Assemblies - CAPE"
context[
"page_description"
] = "Search and view reports from local climate assemblies."
context["page_description"] = (
"Search and view reports from local climate assemblies."
)
return context


Expand Down Expand Up @@ -156,19 +156,19 @@ def get_emissions_context(self, council: Council) -> dict[str, Any]:
latest_year_total_emissions = council_emissions_data.get(
year=latest_year, data_type__name="Total Emissions"
).value
context[
"latest_year_per_capita_emissions"
] = latest_year_per_capita_emissions
context["latest_year_per_capita_emissions"] = (
latest_year_per_capita_emissions
)
context["latest_year_per_km2_emissions"] = latest_year_per_km2_emissions
context["latest_year_total_emissions"] = latest_year_total_emissions
context["emissions_data"] = True
except DataPoint.DoesNotExist as e:
pass

if context["emissions_data"]:
context[
"current_emissions_breakdown"
] = council.current_emissions_breakdown(year=latest_year)
context["current_emissions_breakdown"] = (
council.current_emissions_breakdown(year=latest_year)
)
multi_emission_chart = charts.multi_emissions_chart(council, latest_year)
context["chart_collection"] = ChartCollection()
context["chart_collection"].register(multi_emission_chart)
Expand Down Expand Up @@ -231,9 +231,9 @@ def get_scorecard_context(self, council: Council) -> dict[str, Any]:
"num_sections": len(top_scoring_sections),
}
if len(top_scoring_sections) > 0:
context["scoring_accolades"][
"example_section"
] = top_scoring_sections[0]["description"]
context["scoring_accolades"]["example_section"] = (
top_scoring_sections[0]["description"]
)

context["scoring_hidden"] = getattr(settings, "SCORECARDS_PRIVATE", False)

Expand Down
12 changes: 6 additions & 6 deletions scoring/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1159,12 +1159,12 @@ def get_context_data(self, **kwargs):

context["methodology_year"] = methodology_year
context["toc_template"] = f"scoring/methodology/{methodology_year}/_toc.html"
context[
"intro_template"
] = f"scoring/methodology/{methodology_year}/_intro.html"
context[
"details_template"
] = f"scoring/methodology/{methodology_year}/_details.html"
context["intro_template"] = (
f"scoring/methodology/{methodology_year}/_intro.html"
)
context["details_template"] = (
f"scoring/methodology/{methodology_year}/_details.html"
)

questions = (
PlanQuestion.objects.filter(section__year=methodology_year)
Expand Down
72 changes: 37 additions & 35 deletions scoring2022/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ def get_missing_councils(self, council_ids, authority_type):

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context[
"all_councils"
] = Council.objects.all() # for location search autocomplete
context["all_councils"] = (
Council.objects.all()
) # for location search autocomplete

authority_type = self.get_authority_type()

Expand Down Expand Up @@ -139,9 +139,11 @@ def get_context_data(self, **kwargs):
sorted_by = sort
councils = sorted(
councils,
key=lambda council: 0
if council["score"] == 0 or council["score"] is None
else council["all_scores"][sort]["score"],
key=lambda council: (
0
if council["score"] == 0 or council["score"] is None
else council["all_scores"][sort]["score"]
),
reverse=True,
)
councils = sorted(councils, key=itemgetter("code"))
Expand Down Expand Up @@ -304,18 +306,18 @@ def get_context_data(self, **kwargs):
)

context["comparisons"] = comparisons
context[
"page_description"
] = "Want to know how effective {name}’s climate plans are? Check out {name}’s Council Climate Scorecard to understand how their climate plans compare to local authorities across the UK.".format(
name=council.name
context["page_description"] = (
"Want to know how effective {name}’s climate plans are? Check out {name}’s Council Climate Scorecard to understand how their climate plans compare to local authorities across the UK.".format(
name=council.name
)
)
context[
"twitter_tweet_text"
] = "Up to 30% of the UK’s transition to zero carbon is within the influence of local councils - that’s why I’m checking {name}’s Climate Action Plan on 📋 #CouncilClimateScorecards".format(
name=(
"@{}".format(council.twitter_name)
if council.twitter_name
else council.name
context["twitter_tweet_text"] = (
"Up to 30% of the UK’s transition to zero carbon is within the influence of local councils - that’s why I’m checking {name}’s Climate Action Plan on 📋 #CouncilClimateScorecards".format(
name=(
"@{}".format(council.twitter_name)
if council.twitter_name
else council.name
)
)
)
return context
Expand All @@ -339,9 +341,9 @@ def get_authority_type(self):

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context[
"all_councils"
] = Council.objects.all() # for location search autocomplete
context["all_councils"] = (
Council.objects.all()
) # for location search autocomplete

filter_args = {
"data": self.request.GET or None,
Expand Down Expand Up @@ -496,9 +498,9 @@ class LocationResultsView(PrivateScorecardsAccessMixin, BaseLocationResultsView)

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context[
"all_councils"
] = Council.objects.all() # for location search autocomplete
context["all_councils"] = (
Council.objects.all()
) # for location search autocomplete
context["page_title"] = "Choose a council"
return context

Expand All @@ -509,9 +511,9 @@ class MethodologyView(PrivateScorecardsAccessMixin, TemplateView):

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context[
"all_councils"
] = Council.objects.all() # for location search autocomplete
context["all_councils"] = (
Council.objects.all()
) # for location search autocomplete

# questions = PlanQuestion.objects.all()
# sections = PlanSection.objects.all()
Expand Down Expand Up @@ -562,9 +564,9 @@ class AboutView(PrivateScorecardsAccessMixin, TemplateView):

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context[
"all_councils"
] = Council.objects.all() # for location search autocomplete
context["all_councils"] = (
Council.objects.all()
) # for location search autocomplete
context["page_title"] = "About"
context["current_page"] = "about-page"
return context
Expand All @@ -576,9 +578,9 @@ class ContactView(PrivateScorecardsAccessMixin, TemplateView):

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context[
"all_councils"
] = Council.objects.all() # for location search autocomplete
context["all_councils"] = (
Council.objects.all()
) # for location search autocomplete
context["page_title"] = "Contact"
context["current_page"] = "contact-page"
return context
Expand All @@ -590,9 +592,9 @@ class HowToUseView(TemplateView):

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context[
"all_councils"
] = Council.objects.all() # for location search autocomplete
context["all_councils"] = (
Council.objects.all()
) # for location search autocomplete
context["page_title"] = "How to use the Scorecards"
context["current_page"] = "how-to-page"
return context

0 comments on commit 3bdc2a9

Please sign in to comment.