Skip to content
Merged
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
7 changes: 5 additions & 2 deletions src/api/endpoints/agencies/root/get/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
id: int
name: str
type: AgencyType
jurisdiction_type: JurisdictionType
locations: list[AgencyGetLocationsResponse]
jurisdiction_type: JurisdictionType | None
locations: list[AgencyGetLocationsResponse]

class AgencyGetOuterResponse(BaseModel):

Check warning on line 14 in src/api/endpoints/agencies/root/get/response.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/agencies/root/get/response.py#L14 <101>

Missing docstring in public class
Raw output
./src/api/endpoints/agencies/root/get/response.py:14:1: D101 Missing docstring in public class
results: list[AgencyGetResponse]

Check warning on line 15 in src/api/endpoints/agencies/root/get/response.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/agencies/root/get/response.py#L15 <292>

no newline at end of file
Raw output
./src/api/endpoints/agencies/root/get/response.py:15:37: W292 no newline at end of file
Empty file.
Empty file.
Empty file.
Empty file.
17 changes: 17 additions & 0 deletions src/api/endpoints/data_source/by_id/agency/delete/wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from src.api.endpoints.data_source.by_id.agency.shared.check import check_is_data_source_url

Check warning on line 1 in src/api/endpoints/data_source/by_id/agency/delete/wrapper.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/agency/delete/wrapper.py#L1 <100>

Missing docstring in public module
Raw output
./src/api/endpoints/data_source/by_id/agency/delete/wrapper.py:1:1: D100 Missing docstring in public module
from src.api.shared.agency.delete.query import RemoveURLAgencyLinkQueryBuilder
from src.db.client.async_ import AsyncDatabaseClient


async def delete_data_source_agency_link(

Check warning on line 6 in src/api/endpoints/data_source/by_id/agency/delete/wrapper.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/agency/delete/wrapper.py#L6 <103>

Missing docstring in public function
Raw output
./src/api/endpoints/data_source/by_id/agency/delete/wrapper.py:6:1: D103 Missing docstring in public function
url_id: int,
agency_id: int,
adb_client: AsyncDatabaseClient
) -> None:
await check_is_data_source_url(url_id=url_id, adb_client=adb_client)
await adb_client.run_query_builder(
RemoveURLAgencyLinkQueryBuilder(
url_id=url_id,
agency_id=agency_id
)
)

Check warning on line 17 in src/api/endpoints/data_source/by_id/agency/delete/wrapper.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/agency/delete/wrapper.py#L17 <292>

no newline at end of file
Raw output
./src/api/endpoints/data_source/by_id/agency/delete/wrapper.py:17:6: W292 no newline at end of file
Empty file.
14 changes: 14 additions & 0 deletions src/api/endpoints/data_source/by_id/agency/get/wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from src.api.endpoints.agencies.root.get.response import AgencyGetOuterResponse

Check warning on line 1 in src/api/endpoints/data_source/by_id/agency/get/wrapper.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/agency/get/wrapper.py#L1 <100>

Missing docstring in public module
Raw output
./src/api/endpoints/data_source/by_id/agency/get/wrapper.py:1:1: D100 Missing docstring in public module
from src.api.endpoints.data_source.by_id.agency.shared.check import check_is_data_source_url
from src.api.shared.agency.get.query import GetRelatedAgenciesQueryBuilder
from src.db.client.async_ import AsyncDatabaseClient


async def get_data_source_agencies_wrapper(

Check warning on line 7 in src/api/endpoints/data_source/by_id/agency/get/wrapper.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/agency/get/wrapper.py#L7 <103>

Missing docstring in public function
Raw output
./src/api/endpoints/data_source/by_id/agency/get/wrapper.py:7:1: D103 Missing docstring in public function
url_id: int,
adb_client: AsyncDatabaseClient
) -> AgencyGetOuterResponse:
await check_is_data_source_url(url_id=url_id, adb_client=adb_client)
return await adb_client.run_query_builder(
GetRelatedAgenciesQueryBuilder(url_id=url_id)
)

Check warning on line 14 in src/api/endpoints/data_source/by_id/agency/get/wrapper.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/agency/get/wrapper.py#L14 <292>

no newline at end of file
Raw output
./src/api/endpoints/data_source/by_id/agency/get/wrapper.py:14:6: W292 no newline at end of file
Empty file.
17 changes: 17 additions & 0 deletions src/api/endpoints/data_source/by_id/agency/post/wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from src.api.endpoints.data_source.by_id.agency.shared.check import check_is_data_source_url

Check warning on line 1 in src/api/endpoints/data_source/by_id/agency/post/wrapper.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/agency/post/wrapper.py#L1 <100>

Missing docstring in public module
Raw output
./src/api/endpoints/data_source/by_id/agency/post/wrapper.py:1:1: D100 Missing docstring in public module
from src.api.shared.agency.post.query import AddURLAgencyLinkQueryBuilder
from src.db.client.async_ import AsyncDatabaseClient


async def add_data_source_agency_link(

Check warning on line 6 in src/api/endpoints/data_source/by_id/agency/post/wrapper.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/agency/post/wrapper.py#L6 <103>

Missing docstring in public function
Raw output
./src/api/endpoints/data_source/by_id/agency/post/wrapper.py:6:1: D103 Missing docstring in public function
url_id: int,
agency_id: int,
adb_client: AsyncDatabaseClient
) -> None:
await check_is_data_source_url(url_id=url_id, adb_client=adb_client)
await adb_client.run_query_builder(
AddURLAgencyLinkQueryBuilder(
url_id=url_id,
agency_id=agency_id
)
)

Check warning on line 17 in src/api/endpoints/data_source/by_id/agency/post/wrapper.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/agency/post/wrapper.py#L17 <292>

no newline at end of file
Raw output
./src/api/endpoints/data_source/by_id/agency/post/wrapper.py:17:6: W292 no newline at end of file
Empty file.
17 changes: 17 additions & 0 deletions src/api/endpoints/data_source/by_id/agency/shared/check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from src.api.shared.check.url_type.query import CheckURLTypeQueryBuilder

Check warning on line 1 in src/api/endpoints/data_source/by_id/agency/shared/check.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/agency/shared/check.py#L1 <100>

Missing docstring in public module
Raw output
./src/api/endpoints/data_source/by_id/agency/shared/check.py:1:1: D100 Missing docstring in public module
from src.db.client.async_ import AsyncDatabaseClient
from src.db.models.impl.flag.url_validated.enums import URLType


async def check_is_data_source_url(
url_id: int,
adb_client: AsyncDatabaseClient
) -> None:
"""
Raises:
Bad Request if url_type is not valid or does not exist
"""

await adb_client.run_query_builder(
CheckURLTypeQueryBuilder(url_id=url_id, url_type=URLType.DATA_SOURCE)
)

Check warning on line 17 in src/api/endpoints/data_source/by_id/agency/shared/check.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/agency/shared/check.py#L17 <292>

no newline at end of file
Raw output
./src/api/endpoints/data_source/by_id/agency/shared/check.py:17:6: W292 no newline at end of file
Empty file.
123 changes: 123 additions & 0 deletions src/api/endpoints/data_source/by_id/put/query.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
from sqlalchemy import update, select, literal, insert

Check warning on line 1 in src/api/endpoints/data_source/by_id/put/query.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/query.py#L1 <100>

Missing docstring in public module
Raw output
./src/api/endpoints/data_source/by_id/put/query.py:1:1: D100 Missing docstring in public module

Check warning on line 1 in src/api/endpoints/data_source/by_id/put/query.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/query.py#L1 <401>

'sqlalchemy.insert' imported but unused
Raw output
./src/api/endpoints/data_source/by_id/put/query.py:1:1: F401 'sqlalchemy.insert' imported but unused
from sqlalchemy.ext.asyncio import AsyncSession

from src.api.endpoints.data_source.by_id.put.request import DataSourcePutRequest
from src.api.shared.batch.url.link import UpdateBatchURLLinkQueryBuilder
from src.api.shared.record_type.put.query import UpdateRecordTypeQueryBuilder
from src.api.shared.url.put.query import UpdateURLQueryBuilder
from src.db.models.impl.url.optional_ds_metadata.sqlalchemy import URLOptionalDataSourceMetadata
from src.db.queries.base.builder import QueryBuilderBase


class UpdateDataSourceQueryBuilder(QueryBuilderBase):

Check warning on line 12 in src/api/endpoints/data_source/by_id/put/query.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/query.py#L12 <101>

Missing docstring in public class
Raw output
./src/api/endpoints/data_source/by_id/put/query.py:12:1: D101 Missing docstring in public class

def __init__(

Check warning on line 14 in src/api/endpoints/data_source/by_id/put/query.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/query.py#L14 <107>

Missing docstring in __init__
Raw output
./src/api/endpoints/data_source/by_id/put/query.py:14:1: D107 Missing docstring in __init__
self,
url_id: int,
request: DataSourcePutRequest,
):
super().__init__()
self.url_id = url_id
self.request = request

async def run(self, session: AsyncSession) -> None:

Check warning on line 23 in src/api/endpoints/data_source/by_id/put/query.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/query.py#L23 <102>

Missing docstring in public method
Raw output
./src/api/endpoints/data_source/by_id/put/query.py:23:1: D102 Missing docstring in public method

if self.request.record_type is not None:
await UpdateRecordTypeQueryBuilder(
url_id=self.url_id,
record_type=self.request.record_type
).run(session)

# Update URL if any of the URL fields are not None
if (
self.request.description is None and

Check warning on line 33 in src/api/endpoints/data_source/by_id/put/query.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/query.py#L33 <504>

line break after binary operator
Raw output
./src/api/endpoints/data_source/by_id/put/query.py:33:46: W504 line break after binary operator
self.request.name is None and

Check warning on line 34 in src/api/endpoints/data_source/by_id/put/query.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/query.py#L34 <504>

line break after binary operator
Raw output
./src/api/endpoints/data_source/by_id/put/query.py:34:39: W504 line break after binary operator
self.request.description is None
):
return

# Update Batch if Batch link is none
if self.request.batch_id is not None:
await UpdateBatchURLLinkQueryBuilder(
batch_id=self.request.batch_id,
url_id=self.url_id
).run(session)

await UpdateURLQueryBuilder(
url_id=self.url_id,
url=self.request.url,
name=self.request.name,
description=self.request.description,
).run(
session,
)
if not self.request.optional_data_source_metadata_not_none():
return
value_dict = {}
if self.request.record_formats is not None:
value_dict["record_formats"] = self.request.record_formats
if self.request.data_portal_type is not None:
value_dict["data_portal_type"] = self.request.data_portal_type
if self.request.supplying_entity is not None:
value_dict["supplying_entity"] = self.request.supplying_entity
if self.request.coverage_start is not None:
value_dict["coverage_start"] = self.request.coverage_start
if self.request.coverage_end is not None:
value_dict["coverage_end"] = self.request.coverage_end
if self.request.agency_supplied is not None:
value_dict["agency_supplied"] = self.request.agency_supplied
if self.request.agency_originated is not None:
value_dict["agency_originated"] = self.request.agency_originated
if self.request.agency_aggregation is not None:
value_dict["agency_aggregation"] = self.request.agency_aggregation
if self.request.agency_described_not_in_database is not None:
value_dict["agency_described_not_in_database"] = self.request.agency_described_not_in_database
if self.request.update_method is not None:
value_dict["update_method"] = self.request.update_method
if self.request.readme_url is not None:
value_dict["readme_url"] = self.request.readme_url
if self.request.originating_entity is not None:
value_dict["originating_entity"] = self.request.originating_entity
if self.request.retention_schedule is not None:
value_dict["retention_schedule"] = self.request.retention_schedule
if self.request.scraper_url is not None:
value_dict["scraper_url"] = self.request.scraper_url
if self.request.submission_notes is not None:
value_dict["submission_notes"] = self.request.submission_notes
if self.request.access_notes is not None:
value_dict["access_notes"] = self.request.access_notes
if self.request.access_types is not None:
value_dict["access_types"] = self.request.access_types

# Check for existing metadata object
query = (
select(
literal(True)
)
.where(
URLOptionalDataSourceMetadata.url_id == self.url_id
)
)
exists = await self.sh.one_or_none(session=session, query=query)
if not exists:
insert_obj = URLOptionalDataSourceMetadata(
url_id=self.url_id,
**value_dict
)
session.add(insert_obj)
else:
statement = (
update(
URLOptionalDataSourceMetadata
)
.where(
URLOptionalDataSourceMetadata.url_id == self.url_id
)
.values(
value_dict
)
)

await session.execute(statement)


Check warning on line 123 in src/api/endpoints/data_source/by_id/put/query.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/query.py#L123 <391>

blank line at end of file
Raw output
./src/api/endpoints/data_source/by_id/put/query.py:123:1: W391 blank line at end of file
59 changes: 59 additions & 0 deletions src/api/endpoints/data_source/by_id/put/request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from datetime import date

Check warning on line 1 in src/api/endpoints/data_source/by_id/put/request.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/request.py#L1 <100>

Missing docstring in public module
Raw output
./src/api/endpoints/data_source/by_id/put/request.py:1:1: D100 Missing docstring in public module

from pydantic import BaseModel

from src.core.enums import RecordType
from src.db.models.impl.url.optional_ds_metadata.enums import AgencyAggregationEnum, UpdateMethodEnum, \
RetentionScheduleEnum, AccessTypeEnum


class DataSourcePutRequest(BaseModel):

Check warning on line 10 in src/api/endpoints/data_source/by_id/put/request.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/request.py#L10 <101>

Missing docstring in public class
Raw output
./src/api/endpoints/data_source/by_id/put/request.py:10:1: D101 Missing docstring in public class

# Required Attributes
url: str | None = None
name: str | None = None
record_type: RecordType | None = None

# Optional Attributes
batch_id: int | None = None
description: str | None = None

# Optional data source metadata
record_formats: list[str] | None = None
data_portal_type: str | None = None
supplying_entity: str | None = None
coverage_start: date | None = None
coverage_end: date | None = None
agency_supplied: bool | None = None
agency_originated: bool | None = None
agency_aggregation: AgencyAggregationEnum | None = None
agency_described_not_in_database: str | None = None
update_method: UpdateMethodEnum | None = None
readme_url: str | None = None
originating_entity: str | None = None
retention_schedule: RetentionScheduleEnum | None = None
scraper_url: str | None = None
submission_notes: str | None = None
access_notes: str | None = None
access_types: list[AccessTypeEnum] | None = None

def optional_data_source_metadata_not_none(self) -> bool:

Check warning on line 40 in src/api/endpoints/data_source/by_id/put/request.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/request.py#L40 <102>

Missing docstring in public method
Raw output
./src/api/endpoints/data_source/by_id/put/request.py:40:1: D102 Missing docstring in public method
return (
self.record_formats is not None or

Check warning on line 42 in src/api/endpoints/data_source/by_id/put/request.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/request.py#L42 <504>

line break after binary operator
Raw output
./src/api/endpoints/data_source/by_id/put/request.py:42:45: W504 line break after binary operator
self.data_portal_type is not None or

Check warning on line 43 in src/api/endpoints/data_source/by_id/put/request.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/request.py#L43 <504>

line break after binary operator
Raw output
./src/api/endpoints/data_source/by_id/put/request.py:43:47: W504 line break after binary operator
self.supplying_entity is not None or

Check warning on line 44 in src/api/endpoints/data_source/by_id/put/request.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/request.py#L44 <504>

line break after binary operator
Raw output
./src/api/endpoints/data_source/by_id/put/request.py:44:47: W504 line break after binary operator
self.coverage_start is not None or

Check warning on line 45 in src/api/endpoints/data_source/by_id/put/request.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/request.py#L45 <504>

line break after binary operator
Raw output
./src/api/endpoints/data_source/by_id/put/request.py:45:45: W504 line break after binary operator
self.coverage_end is not None or

Check warning on line 46 in src/api/endpoints/data_source/by_id/put/request.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/request.py#L46 <504>

line break after binary operator
Raw output
./src/api/endpoints/data_source/by_id/put/request.py:46:43: W504 line break after binary operator
self.agency_supplied is not None or

Check warning on line 47 in src/api/endpoints/data_source/by_id/put/request.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/request.py#L47 <504>

line break after binary operator
Raw output
./src/api/endpoints/data_source/by_id/put/request.py:47:46: W504 line break after binary operator
self.agency_originated is not None or

Check warning on line 48 in src/api/endpoints/data_source/by_id/put/request.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/request.py#L48 <504>

line break after binary operator
Raw output
./src/api/endpoints/data_source/by_id/put/request.py:48:48: W504 line break after binary operator
self.agency_aggregation is not None or

Check warning on line 49 in src/api/endpoints/data_source/by_id/put/request.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/request.py#L49 <504>

line break after binary operator
Raw output
./src/api/endpoints/data_source/by_id/put/request.py:49:49: W504 line break after binary operator
self.agency_described_not_in_database is not None or

Check warning on line 50 in src/api/endpoints/data_source/by_id/put/request.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/request.py#L50 <504>

line break after binary operator
Raw output
./src/api/endpoints/data_source/by_id/put/request.py:50:63: W504 line break after binary operator
self.update_method is not None or

Check warning on line 51 in src/api/endpoints/data_source/by_id/put/request.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/request.py#L51 <504>

line break after binary operator
Raw output
./src/api/endpoints/data_source/by_id/put/request.py:51:44: W504 line break after binary operator
self.readme_url is not None or

Check warning on line 52 in src/api/endpoints/data_source/by_id/put/request.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/request.py#L52 <504>

line break after binary operator
Raw output
./src/api/endpoints/data_source/by_id/put/request.py:52:41: W504 line break after binary operator
self.originating_entity is not None or

Check warning on line 53 in src/api/endpoints/data_source/by_id/put/request.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/request.py#L53 <504>

line break after binary operator
Raw output
./src/api/endpoints/data_source/by_id/put/request.py:53:49: W504 line break after binary operator
self.retention_schedule is not None or

Check warning on line 54 in src/api/endpoints/data_source/by_id/put/request.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/request.py#L54 <504>

line break after binary operator
Raw output
./src/api/endpoints/data_source/by_id/put/request.py:54:49: W504 line break after binary operator
self.scraper_url is not None or

Check warning on line 55 in src/api/endpoints/data_source/by_id/put/request.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/request.py#L55 <504>

line break after binary operator
Raw output
./src/api/endpoints/data_source/by_id/put/request.py:55:42: W504 line break after binary operator
self.submission_notes is not None or

Check warning on line 56 in src/api/endpoints/data_source/by_id/put/request.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/request.py#L56 <504>

line break after binary operator
Raw output
./src/api/endpoints/data_source/by_id/put/request.py:56:47: W504 line break after binary operator
self.access_notes is not None or

Check warning on line 57 in src/api/endpoints/data_source/by_id/put/request.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/request.py#L57 <504>

line break after binary operator
Raw output
./src/api/endpoints/data_source/by_id/put/request.py:57:43: W504 line break after binary operator
self.access_types is not None
)

Check warning on line 59 in src/api/endpoints/data_source/by_id/put/request.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/api/endpoints/data_source/by_id/put/request.py#L59 <292>

no newline at end of file
Raw output
./src/api/endpoints/data_source/by_id/put/request.py:59:10: W292 no newline at end of file
Empty file.
Loading