Skip to content

Commit

Permalink
💄 Update ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
Marigold committed Dec 9, 2024
1 parent 858da07 commit 5a35fd2
Show file tree
Hide file tree
Showing 667 changed files with 1,758 additions and 889 deletions.
3 changes: 1 addition & 2 deletions apps/chart_animation/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Create a GIF or video for a given chart URL.
"""Create a GIF or video for a given chart URL."""

"""
from concurrent.futures import ThreadPoolExecutor, as_completed
from pathlib import Path
from urllib.parse import parse_qs, urlencode, urlparse, urlunparse
Expand Down
6 changes: 3 additions & 3 deletions apps/metadata_migrate/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ def cli(

# empty fields to be filled
vars[col]["presentation"] = {}
vars[col]["presentation"][
"title_public"
] = "TBD - Indicator title to be shown in data pages, that overrides the indicator's title."
vars[col]["presentation"]["title_public"] = (
"TBD - Indicator title to be shown in data pages, that overrides the indicator's title."
)
vars[col]["presentation"]["title_variant"] = "TBD - Indicator's title variant"
vars[col]["presentation"]["attribution_short"] = "TBD - Indicator's attribution (shorter version)"
vars[col]["presentation"]["faqs"] = [
Expand Down
1 change: 1 addition & 0 deletions apps/metagpt/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Client module."""

import os
from typing import Any, Dict, Literal, cast

Expand Down
1 change: 1 addition & 0 deletions apps/metagpt/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Contains instructions to correctly query chat GPT for the different use cases (snapshot, garden, grapher, etc.). This includes details on what each metadata field means.
"""

import json
from typing import Any, Dict, List

Expand Down
1 change: 1 addition & 0 deletions apps/metagpt/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Auxiliary utils for metagpt app."""

from pathlib import Path
from typing import Dict, List

Expand Down
1 change: 1 addition & 0 deletions apps/utils/gpt.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Auxiliary classes, functions and variables."""

from dataclasses import asdict, dataclass, field
from typing import Any, Dict, List, Optional, Tuple

Expand Down
1 change: 1 addition & 0 deletions apps/wizard/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
NOTE: This only works with >1.35 (nightly) version of Streamlit.
"""

import streamlit as st

from apps.wizard.config import WIZARD_CONFIG
Expand Down
1 change: 1 addition & 0 deletions apps/wizard/app_pages/anomalist/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utils for chart revision tool."""

import time
from enum import Enum
from typing import Dict, List, Optional, Tuple
Expand Down
1 change: 1 addition & 0 deletions apps/wizard/app_pages/chart_diff/chart_diff_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
If you want to learn more about it, start from its `show` method.
"""

import difflib
import json
import os
Expand Down
3 changes: 1 addition & 2 deletions apps/wizard/app_pages/dashboard.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Create a dashboard with the main information about ETL steps, and the possibility to update them.
"""Create a dashboard with the main information about ETL steps, and the possibility to update them."""

"""
import subprocess
from datetime import datetime

Expand Down
1 change: 1 addition & 0 deletions apps/wizard/app_pages/dataset_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- [ ] See its dependencies
- [ ] Preview its metadata
"""

import tempfile
from typing import Any, Dict, List, cast

Expand Down
1 change: 1 addition & 0 deletions apps/wizard/app_pages/expert/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
references:
- https://docs.streamlit.io/knowledge-base/tutorials/build-conversational-apps#build-a-chatgpt-like-app
"""

from typing import Any, Dict, cast

import streamlit as st
Expand Down
3 changes: 2 additions & 1 deletion apps/wizard/app_pages/expert/prompts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""""Get prompts for GPT-interaction."""
""" "Get prompts for GPT-interaction."""

import glob
from typing import List

Expand Down
1 change: 1 addition & 0 deletions apps/wizard/app_pages/explorer_edit.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Helper tool to create map brackets for all indicators in an indicator-based explorer."""

from io import StringIO

import streamlit as st
Expand Down
1 change: 1 addition & 0 deletions apps/wizard/app_pages/fasttrack/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
TODO: Fully decouple front-end from backend (see fasttrack.utils for back-end, i.e. should not have streamlit calls).
"""

from pathlib import Path

import pandas as pd
Expand Down
1 change: 1 addition & 0 deletions apps/wizard/app_pages/fasttrack/fast_import.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Definition of FasttrackImport object (mainly backend)."""

import datetime as dt
import difflib
import html
Expand Down
1 change: 1 addition & 0 deletions apps/wizard/app_pages/fasttrack/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Relies on Streamlit to print messages.
"""

import concurrent.futures
import datetime as dt
import json
Expand Down
1 change: 1 addition & 0 deletions apps/wizard/app_pages/fasttrack/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Relies on Streamlit.
"""

import json
from typing import Dict, List, Tuple

Expand Down
1 change: 1 addition & 0 deletions apps/wizard/app_pages/fasttrack/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utils."""

import os
from typing import Any, Dict, Optional

Expand Down
1 change: 1 addition & 0 deletions apps/wizard/app_pages/harmonizer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Harmonize entities."""

import json
from operator import itemgetter
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions apps/wizard/app_pages/indicator_upgrade/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- Set to True: When the user clicks on "Finish (3/3)" in the third form.
- Set to False:
"""

import streamlit as st
from structlog import get_logger

Expand Down
1 change: 1 addition & 0 deletions apps/wizard/app_pages/indicator_upgrade/charts_update.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Handle submission of chart updates."""

from http.client import RemoteDisconnected
from typing import Dict, List
from urllib.error import URLError
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Search configuration."""

from typing import Any, Dict

import pandas as pd
Expand Down
1 change: 1 addition & 0 deletions apps/wizard/app_pages/indicator_upgrade/explore_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This is currently shown in the indicator upgrader, but might be moved to chart-diff in the future.
"""

from dataclasses import dataclass, field
from typing import Dict, Optional, Tuple, cast

Expand Down
1 change: 1 addition & 0 deletions apps/wizard/app_pages/indicator_upgrade/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utils for chart revision tool."""

from typing import Dict, Tuple, cast

import pandas as pd
Expand Down
4 changes: 1 addition & 3 deletions apps/wizard/app_pages/map_brackets.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Helper tool to create map brackets for all indicators in an indicator-based explorer.
"""
"""Helper tool to create map brackets for all indicators in an indicator-based explorer."""

import json
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions apps/wizard/app_pages/metagpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Note that it still relies on apps/metagpt.
"""

import os
import tempfile
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions apps/wizard/app_pages/metaplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
streamlit run app.py
"""

import webbrowser
from pathlib import Path

Expand Down
1 change: 1 addition & 0 deletions apps/wizard/app_pages/news.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Display news from ETL."""

from datetime import datetime

import streamlit as st
Expand Down
1 change: 1 addition & 0 deletions apps/wizard/app_pages/owidle.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Game owidle."""

import datetime as dt
import math
from itertools import product
Expand Down
1 change: 1 addition & 0 deletions apps/wizard/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
python cli.py
"""

import logging
import sys
from typing import Iterable
Expand Down
1 change: 1 addition & 0 deletions apps/wizard/etl_steps/express.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Garden phase."""

from datetime import date, datetime, timedelta
from pathlib import Path
from typing import Any, Dict, List
Expand Down
7 changes: 4 additions & 3 deletions apps/wizard/etl_steps/garden.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Garden phase."""

import os
from pathlib import Path
from typing import List, cast
Expand Down Expand Up @@ -452,9 +453,9 @@ def export_metadata() -> None:
f"Use the generated notebook `{notebook_path.relative_to(BASE_DIR)}` to examine the dataset output interactively."
)
# B/ Generate metadata
st.session_state[
"garden.dataset_path"
] = f"data/garden/{form.namespace}/{form.version}/{form.short_name}"
st.session_state["garden.dataset_path"] = (
f"data/garden/{form.namespace}/{form.version}/{form.short_name}"
)
st.markdown("#### Generate metadata")
st.markdown(f"Generate metadata file `{form.short_name}.meta.yml` from your dataset with:")
st.button(
Expand Down
1 change: 1 addition & 0 deletions apps/wizard/etl_steps/grapher.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Grapher phase."""

from pathlib import Path
from typing import cast

Expand Down
1 change: 1 addition & 0 deletions apps/wizard/etl_steps/meadow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Meadow phase."""

import os
from pathlib import Path
from typing import cast
Expand Down
1 change: 1 addition & 0 deletions apps/wizard/etl_steps/snapshot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Snapshot phase."""

import os
import subprocess
import traceback
Expand Down
1 change: 1 addition & 0 deletions apps/wizard/home.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Home page of wizard."""

from copy import deepcopy
from typing import Any, Dict, List, Optional

Expand Down
1 change: 1 addition & 0 deletions apps/wizard/scripts/news.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Methods to update Wizard DB to have the necessary PR data."""

from typing import Tuple

import requests
Expand Down
1 change: 1 addition & 0 deletions apps/wizard/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
Also, can imagine apps/wizard/ being renamed to just wizard/, and stuff other than wizard should be either (i) deleted or (ii) migrated elsewhere in etl/.
"""

import argparse
import ast
import datetime as dt
Expand Down
1 change: 1 addition & 0 deletions apps/wizard/utils/chart_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tools to generate chart configs."""

from copy import deepcopy
from typing import Any, Dict, List, Optional

Expand Down
1 change: 1 addition & 0 deletions apps/wizard/utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Some of the tools here rely on a local temporary sqlite database. This database is a custom and temporary database used to store data in a server. Not intended for production use.
"""

import datetime as dt
import hashlib
import os
Expand Down
1 change: 1 addition & 0 deletions apps/wizard/utils/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Together with utils.db and utils.cached, it might need some rethinking on where it goes.
"""

from pathlib import Path
from typing import Dict, List, Optional

Expand Down
1 change: 1 addition & 0 deletions docs/ignore/generate_dynamic_docs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Generate documentation files dynamically"""

import mkdocs_gen_files

from etl.docs import render_dataset, render_indicator, render_origin, render_table
Expand Down
1 change: 1 addition & 0 deletions etl/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
The environment variables and settings here are for publishing options, they're
only important for OWID staff.
"""

import os
import pwd
import re
Expand Down
1 change: 1 addition & 0 deletions etl/data_helpers/population.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tools to load population data."""

from typing import Any, Dict, Optional

import pandas as pd
Expand Down
1 change: 1 addition & 0 deletions etl/explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Compare content and content_raw
- Test it in Pablo's scripts
"""

from copy import copy
from io import StringIO
from pathlib import Path
Expand Down
6 changes: 2 additions & 4 deletions etl/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,13 @@ def yaml_dump(
strip_lines: bool = True,
replace_confusing_ascii: bool = False,
width: int = 120,
) -> str:
...
) -> str: ...


@overload
def yaml_dump(
d: Dict[str, Any], stream: TextIO, strip_lines: bool = True, replace_confusing_ascii: bool = False, width: int = 120
) -> None:
...
) -> None: ...


def yaml_dump(
Expand Down
1 change: 1 addition & 0 deletions etl/grapher_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Code using db_conn (pymysql.Connection objects). We should instead use sessions, or engines (or OWIDEnv)
"""

import concurrent.futures
import io
import warnings
Expand Down
Loading

0 comments on commit 5a35fd2

Please sign in to comment.