Skip to content

Commit

Permalink
chore: Lint Cleanup (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
RickiJay-WMDE authored Nov 12, 2024
1 parent 8936521 commit 183f5d8
Show file tree
Hide file tree
Showing 57 changed files with 224 additions and 235 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ jobs:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.10.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -25,8 +23,6 @@ jobs:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.10.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -40,8 +36,6 @@ jobs:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.10.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -55,8 +49,6 @@ jobs:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.10.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion data/database_connection.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Database Connection"""

from collections.abc import AsyncGenerator
from contextlib import asynccontextmanager
from typing import AsyncGenerator

from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
from sqlalchemy.orm import sessionmaker
Expand Down
35 changes: 30 additions & 5 deletions data/gx/expectations/wikibase_expectation_suite.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@
"id": "5342a046-55a7-4a61-908e-c461cd4a84bf",
"kwargs": {
"column": "wikibase_name",
"regex_list": ["^[ \t\r\n]*$", "^[ \t\r\n]+", "[ \t\r\n]+$"]
"regex_list": [
"^[ \t\r\n]*$",
"^[ \t\r\n]+",
"[ \t\r\n]+$",
"[ \t\r\n]{2,}"
]
},
"meta": {},
"type": "expect_column_values_to_not_match_regex_list"
Expand All @@ -49,7 +54,12 @@
"id": "d4ffc143-e54a-4ad9-af88-b5c38eee60a4",
"kwargs": {
"column": "organization",
"regex_list": ["^[ \t\r\n]*$", "^[ \t\r\n]+", "[ \t\r\n]+$"]
"regex_list": [
"^[ \t\r\n]*$",
"^[ \t\r\n]+",
"[ \t\r\n]+$",
"[ \t\r\n]{2,}"
]
},
"meta": {},
"type": "expect_column_values_to_not_match_regex_list"
Expand All @@ -64,7 +74,12 @@
"id": "43da03cf-e685-4bbd-979c-ffd8e16aeed7",
"kwargs": {
"column": "country",
"regex_list": ["^[ \t\r\n]*$", "^[ \t\r\n]+", "[ \t\r\n]+$"]
"regex_list": [
"^[ \t\r\n]*$",
"^[ \t\r\n]+",
"[ \t\r\n]+$",
"[ \t\r\n]{2,}"
]
},
"meta": {},
"type": "expect_column_values_to_not_match_regex_list"
Expand All @@ -79,7 +94,12 @@
"id": "9ce6b575-0119-4dac-8d65-d1a210e6f423",
"kwargs": {
"column": "region",
"regex_list": ["^[ \t\r\n]*$", "^[ \t\r\n]+", "[ \t\r\n]+$"]
"regex_list": [
"^[ \t\r\n]*$",
"^[ \t\r\n]+",
"[ \t\r\n]+$",
"[ \t\r\n]{2,}"
]
},
"meta": {},
"type": "expect_column_values_to_not_match_regex_list"
Expand Down Expand Up @@ -136,7 +156,12 @@
"id": "ca289730-c632-4991-81c5-f31eef1cee75",
"kwargs": {
"column": "description",
"regex_list": ["^[ \t\r\n]*$", "^[ \t\r\n]+", "[ \t\r\n]+$"]
"regex_list": [
"^[ \t\r\n]*$",
"^[ \t\r\n]+",
"[ \t\r\n]+$",
"[ \t\r\n]{2,}"
]
},
"meta": {},
"type": "expect_column_values_to_not_match_regex_list"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@
"id": "77b293b1-73c2-437a-a035-3adfb66294bd",
"kwargs": {
"column": "property_url",
"regex_list": ["^[ \t\r\n]*$", "^[ \t\r\n]+", "[ \t\r\n]+$"]
"regex_list": [
"^[ \t\r\n]*$",
"^[ \t\r\n]+",
"[ \t\r\n]+$",
"[ \t\r\n]{2,}"
]
},
"meta": {},
"type": "expect_column_values_to_not_match_regex_list"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@
"id": "78894d21-05f1-470d-931b-3efe46132d2e",
"kwargs": {
"column": "version",
"regex_list": ["^[ \t\r\n]*$", "^[ \t\r\n]+", "[ \t\r\n]+$"]
"regex_list": [
"^[ \t\r\n]*$",
"^[ \t\r\n]+",
"[ \t\r\n]+$",
"[ \t\r\n]{2,}"
]
},
"meta": {},
"type": "expect_column_values_to_not_match_regex_list"
Expand Down
7 changes: 6 additions & 1 deletion data/gx/expectations/wikibase_url_expectation_suite.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@
"id": "31ae4f4f-55f0-4ac7-8e0d-3f17fe4fe823",
"kwargs": {
"column": "url",
"regex_list": ["^[ \t\r\n]*$", "^[ \t\r\n]+", "[ \t\r\n]+$"]
"regex_list": [
"^[ \t\r\n]*$",
"^[ \t\r\n]+",
"[ \t\r\n]+$",
"[ \t\r\n]{2,}"
]
},
"meta": {},
"type": "expect_column_values_to_not_match_regex_list"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@
"id": "67a3cb18-3559-471d-ba6c-ef4385a9b96b",
"kwargs": {
"column": "group_name",
"regex_list": ["^[ \t\r\n]*$", "^[ \t\r\n]+", "[ \t\r\n]+$"]
"regex_list": [
"^[ \t\r\n]*$",
"^[ \t\r\n]+",
"[ \t\r\n]+$",
"[ \t\r\n]{2,}"
]
},
"meta": {},
"type": "expect_column_values_to_not_match_regex_list"
Expand Down
4 changes: 2 additions & 2 deletions fetch_data/api_data/log_data/create_log_observation.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Create Log Observation"""

from collections.abc import Iterable
from datetime import datetime
from json.decoder import JSONDecodeError
from typing import List
from requests.exceptions import ReadTimeout, SSLError
from data import get_async_session
from fetch_data.api_data.log_data.fetch_log_data import (
Expand Down Expand Up @@ -85,7 +85,7 @@ async def create_log_observation(wikibase_id: int) -> bool:


async def create_log_month(
wikibase: WikibaseModel, log_list: List[WikibaseLogRecord]
wikibase: WikibaseModel, log_list: Iterable[WikibaseLogRecord]
) -> WikibaseLogMonthObservationModel:
"""Create Log Month"""

Expand Down
10 changes: 5 additions & 5 deletions fetch_data/api_data/log_data/fetch_log_data.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Fetch Log Data"""

from datetime import datetime
from typing import List, Optional
from typing import Optional
from fetch_data.api_data.log_data.wikibase_log_record import WikibaseLogRecord
from fetch_data.utils import dict_to_url, fetch_api_data

Expand All @@ -24,10 +24,10 @@ def get_log_param_string(
return dict_to_url(parameters)


def get_log_list_from_url(url: str) -> List[WikibaseLogRecord]:
def get_log_list_from_url(url: str) -> list[WikibaseLogRecord]:
"""Get Log List from URL"""

data = []
data: list[WikibaseLogRecord] = []

query_data = fetch_api_data(url)
for record in query_data["query"]["logevents"]:
Expand All @@ -38,10 +38,10 @@ def get_log_list_from_url(url: str) -> List[WikibaseLogRecord]:

def get_month_log_list(
api_url: str, comparison_date: datetime, oldest: bool = False
) -> List[WikibaseLogRecord]:
) -> list[WikibaseLogRecord]:
"""Get Log List from api_url, limit to within 30 days of the comparison date"""

data: List[WikibaseLogRecord] = []
data: list[WikibaseLogRecord] = []
limit = 500

should_query = True
Expand Down
2 changes: 1 addition & 1 deletion fetch_data/api_data/user_data/fetch_multiple_user_data.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Fetch Multiple User Data"""

from collections.abc import Iterable
import json
from typing import Iterable
import requests
from fetch_data.api_data.user_data.user_data_url import user_url
from model.database import WikibaseModel
Expand Down
18 changes: 9 additions & 9 deletions fetch_data/soup_data/create_software_version_data_observation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Create Software Version Observation"""

from collections.abc import Iterable
from datetime import datetime
from typing import List
from urllib.error import HTTPError
from bs4 import BeautifulSoup, Tag
import requests
Expand Down Expand Up @@ -61,7 +61,7 @@ async def create_software_version_observation(wikibase_id: int) -> bool:

def compile_extension_versions(
soup: BeautifulSoup,
) -> List[WikibaseSoftwareVersionModel]:
) -> list[WikibaseSoftwareVersionModel]:
"""Compile Extension Version List"""

extensions_table = soup.find(
Expand All @@ -79,12 +79,12 @@ def compile_extension_versions(

def compile_installed_software_versions(
soup: BeautifulSoup,
) -> List[WikibaseSoftwareVersionModel]:
) -> list[WikibaseSoftwareVersionModel]:
"""Compile Installed Software Version List"""

installed_software_table: Tag = soup.find("table", attrs={"id": "sv-software"})

software_versions: List[WikibaseSoftwareVersionModel] = []
software_versions: list[WikibaseSoftwareVersionModel] = []
row: Tag
for row in installed_software_table.find_all("tr"):
if row.find("td"):
Expand Down Expand Up @@ -124,12 +124,12 @@ def compile_installed_software_versions(
return software_versions


def compile_library_versions(soup: BeautifulSoup) -> List[WikibaseSoftwareVersionModel]:
def compile_library_versions(soup: BeautifulSoup) -> list[WikibaseSoftwareVersionModel]:
"""Compile Library Version List"""

libraries_table = soup.find("table", attrs={"id": "sv-libraries"})

library_versions: List[WikibaseSoftwareVersionModel] = []
library_versions: list[WikibaseSoftwareVersionModel] = []
row: Tag
for row in libraries_table.find_all("tr"):
if row.find("td"):
Expand All @@ -149,7 +149,7 @@ def compile_library_versions(soup: BeautifulSoup) -> List[WikibaseSoftwareVersio
return unique_versions(library_versions)


def compile_skin_versions(soup: BeautifulSoup) -> List[WikibaseSoftwareVersionModel]:
def compile_skin_versions(soup: BeautifulSoup) -> list[WikibaseSoftwareVersionModel]:
"""Compile Skin Version List"""

installed_skin_table: Tag = soup.find(
Expand Down Expand Up @@ -214,8 +214,8 @@ def get_software_version_from_row(


def unique_versions(
input_list: List[WikibaseSoftwareVersionModel],
) -> List[WikibaseSoftwareVersionModel]:
input_list: Iterable[WikibaseSoftwareVersionModel],
) -> list[WikibaseSoftwareVersionModel]:
"""Unique Version List"""

temp: dict[str, WikibaseSoftwareVersionModel] = {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Compile Connectivity Distance"""

from typing import Iterable, List
from collections.abc import Iterable
from tqdm import tqdm


def compile_distance_dict(
all_nodes: List[str], link_dict: dict[str, set[str]]
all_nodes: Iterable[str], link_dict: dict[str, set[str]]
) -> dict[str, dict[str, int]]:
"""Compile Distance Dictionary
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Compile Link Dictionary"""

from typing import List
from collections.abc import Iterable
from fetch_data.sparql_data.sparql_queries import ItemLink


def compile_link_dict(
clean_data: List[ItemLink], all_nodes: List[str], reverse: bool = False
clean_data: Iterable[ItemLink], all_nodes: Iterable[str], reverse: bool = False
) -> dict[str, set[str]]:
"""Compile Link Dictionary
Expand Down
3 changes: 1 addition & 2 deletions fetch_data/sparql_data/sparql_queries/item_links.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Links between items"""

import re
from typing import List


ITEM_LINKS_QUERY = """SELECT ?item ?object WHERE {
Expand Down Expand Up @@ -36,7 +35,7 @@ def clean_point(point: dict) -> ItemLink:
)


def clean_item_link_data(results: dict) -> List[ItemLink]:
def clean_item_link_data(results: dict) -> list[ItemLink]:
"""Query Results to list of data"""

return [clean_point(p) for p in results["results"]["bindings"]]
3 changes: 2 additions & 1 deletion fetch_data/utils/counts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Counts"""

from typing import Iterable, TypeVar
from collections.abc import Iterable
from typing import TypeVar


T = TypeVar("T")
Expand Down
3 changes: 1 addition & 2 deletions model/database/wikibase_category_model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Wikibase Category Table"""

from typing import List
from sqlalchemy import Enum, Integer, UniqueConstraint
from sqlalchemy.orm import Mapped, mapped_column, relationship

Expand All @@ -18,7 +17,7 @@ class WikibaseCategoryModel(ModelBase):
id: Mapped[int] = mapped_column("id", Integer, primary_key=True, autoincrement=True)
"""ID"""

wikibases: Mapped[List["WikibaseModel"]] = relationship(
wikibases: Mapped[list["WikibaseModel"]] = relationship(
"WikibaseModel", lazy="selectin", back_populates="category"
)
"""Wikibases"""
Expand Down
Loading

0 comments on commit 183f5d8

Please sign in to comment.