Skip to content
Snippets Groups Projects
Commit 08b81999 authored by Tim Repke's avatar Tim Repke
Browse files

fix flake and mypy

parent 7a00bc19
No related branches found
No related tags found
1 merge request!53OpenAlex Search and pydantic v2 migration
Pipeline #1840 failed
......@@ -38,7 +38,7 @@ async def emit(event: Event) -> None:
emit_event = emit_event_type.model_validate(event.payload)
logger.debug(f'Going to emit {emit_event} ({emit_event})')
await eventbus.emit_async(emit_event._name, emit_event) # noqa PyProtectedMember
await eventbus.emit_async(emit_event.name, emit_event) # noqa PyProtectedMember
# TODO user-configurable triggers (e.g. trigger on event or cron-like)
# - create schema, model, crud in nacsos-data (probably could just be a JSONB field in `Project`
......
......@@ -41,7 +41,7 @@ class ServerConfig(BaseModel):
return [i.strip() for i in v.split(',')]
if isinstance(v, str) and v.startswith('['):
ret = json.loads(v)
if type(ret) == list:
if type(ret) is list:
return ret
elif isinstance(v, (list, str)):
return v
......@@ -50,6 +50,7 @@ class ServerConfig(BaseModel):
class DatabaseConfig(BaseModel):
SCHEME: str = 'postgresql'
SCHEMA: str = 'public'
HOST: str = 'localhost' # host of the db server
PORT: int = 5432 # port of the db server
USER: str = 'nacsos' # username for the database
......@@ -113,13 +114,19 @@ class PipelinesConfig(BaseModel):
class Settings(BaseSettings):
# Basic server hosting settings
SERVER: ServerConfig = ServerConfig()
# Database connection to main database
DB: DatabaseConfig = DatabaseConfig()
# Global user account settings
USERS: UsersConfig = UsersConfig()
# Settings for the nacsos-pipelines API
PIPES: PipelinesConfig = PipelinesConfig()
# OpenAlex in PostgreSQL
OA_DB: DatabaseConfig = DatabaseConfig()
# URL including path to OpenAlex collection
OPENALEX: AnyHttpUrl = 'http://localhost:8983/solr/openalex'
OA_SOLR: AnyHttpUrl = 'http://localhost:8983/solr/openalex' # type: ignore[assignment]
# EMAIL: EmailConfig
......@@ -137,7 +144,7 @@ class Settings(BaseSettings):
if filename is not None:
with open(filename, 'r') as f:
ret = toml.loads(f.read())
if type(ret) == dict:
if type(ret) is dict:
return ret
raise ValueError('Logging config invalid!')
......
......@@ -47,7 +47,7 @@ class ErrorHandlingMiddleware(BaseHTTPMiddleware):
def _resolve_status(cls, ew: Error) -> int:
if hasattr(ew, 'status'):
error_status = getattr(ew, 'status')
if type(error_status) == int:
if type(error_status) is int:
return error_status
return http_status.HTTP_400_BAD_REQUEST
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment