Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(RUF012) Fixed mutable class Defaults- Task 2 #10286

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3ffa83a
Task-2 RUF012
ananyakaligal Jan 6, 2025
78793a6
Task-2 RUF012
ananyakaligal Jan 6, 2025
da290a6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 6, 2025
b3ce893
Task-2 RUF012
ananyakaligal Jan 6, 2025
4b7e0c2
Task-2 RUF012
ananyakaligal Jan 6, 2025
420c8a6
Task-2 RUF012
ananyakaligal Jan 6, 2025
6b2e6f6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 6, 2025
f027ffb
Task-2 RUF012
ananyakaligal Jan 6, 2025
d468b76
Task-2 RUF012
ananyakaligal Jan 6, 2025
d4bc035
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 6, 2025
156f104
ruff RUF012
ananyakaligal Jan 23, 2025
86d4736
RUF012
ananyakaligal Jan 23, 2025
db0b236
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 23, 2025
014a672
Merge branch 'internetarchive:master' into task--2
ananyakaligal Jan 23, 2025
aa86e8a
RUF012
ananyakaligal Jan 23, 2025
e42a247
Merge branch 'task--2' of github.com:ananyakaligal/openlibrary into t…
ananyakaligal Jan 23, 2025
9337a7c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 23, 2025
2165888
RUF012
ananyakaligal Jan 23, 2025
631fab2
Merge branch 'task--2' of github.com:ananyakaligal/openlibrary into t…
ananyakaligal Jan 23, 2025
1bc0aaa
RUF012
ananyakaligal Jan 23, 2025
cc36cd9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 23, 2025
65dee5c
RUF012
ananyakaligal Jan 23, 2025
1220436
RUF012
ananyakaligal Jan 23, 2025
dd0f305
RUF012
ananyakaligal Jan 23, 2025
7ff015c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 23, 2025
a9c0b85
RUF012
ananyakaligal Jan 23, 2025
0964b5a
Merge branch 'task--2' of github.com:ananyakaligal/openlibrary into t…
ananyakaligal Jan 23, 2025
e6f894b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 23, 2025
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
16 changes: 9 additions & 7 deletions openlibrary/tests/core/test_db.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import ClassVar

import web

from openlibrary.core.booknotes import Booknotes
Expand Down Expand Up @@ -156,7 +158,7 @@ def test_no_allow_delete_on_conflict(self):


class TestUsernameUpdate:
READING_LOG_SETUP_ROWS = [
READING_LOG_SETUP_ROWS: ClassVar[list[dict[str, str | int]]] = [
{
"username": "@kilgore_trout",
"work_id": 1,
Expand All @@ -176,15 +178,15 @@ class TestUsernameUpdate:
"bookshelf_id": 2,
},
]
BOOKNOTES_SETUP_ROWS = [
BOOKNOTES_SETUP_ROWS: ClassVar[list[dict[str, str | int]]] = [
{"username": "@kilgore_trout", "work_id": 1, "edition_id": 1, "notes": "Hello"},
{"username": "@billy_pilgrim", "work_id": 1, "edition_id": 1, "notes": "World"},
]
RATINGS_SETUP_ROWS = [
RATINGS_SETUP_ROWS: ClassVar[list[dict[str, str | int]]] = [
{"username": "@kilgore_trout", "work_id": 1, "edition_id": 1, "rating": 4},
{"username": "@billy_pilgrim", "work_id": 5, "edition_id": 1, "rating": 2},
]
OBSERVATIONS_SETUP_ROWS = [
OBSERVATIONS_SETUP_ROWS: ClassVar[list[dict[str, str | int]]] = [
{
"username": "@kilgore_trout",
"work_id": 1,
Expand All @@ -201,7 +203,7 @@ class TestUsernameUpdate:
},
]

EDITS_QUEUE_SETUP_ROWS = [
EDITS_QUEUE_SETUP_ROWS: ClassVar[list[dict[str, str | int | None]]] = [
{
"title": "One Fish, Two Fish, Red Fish, Blue Fish",
"submitter": "@kilgore_trout",
Expand Down Expand Up @@ -308,7 +310,7 @@ def test_update_username(self):


class TestCheckIns:
BOOKSHELVES_EVENTS_SETUP_ROWS = [
BOOKSHELVES_EVENTS_SETUP_ROWS: ClassVar[list[dict[str, str | int]]] = [
{
"id": 1,
"username": "@kilgore_trout",
Expand Down Expand Up @@ -481,7 +483,7 @@ def test_get_latest_event_date(self):


class TestYearlyReadingGoals:
SETUP_ROWS = [
SETUP_ROWS: ClassVar[list[dict[str, str | int]]] = [
{
'username': '@billy_pilgrim',
'year': 2022,
Expand Down
14 changes: 8 additions & 6 deletions openlibrary/utils/schema.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import ClassVar

"""utility to generate db schema for any database engine.
(should go to web.py)
"""
Expand Down Expand Up @@ -94,7 +96,7 @@ def quote(self, value):


class MySQLAdapter(AbstractAdapter):
native_types = {
native_types: ClassVar[dict[str, str]] = {
'serial': 'int auto_increment not null',
'integer': 'int',
'float': 'float',
Expand All @@ -107,7 +109,7 @@ class MySQLAdapter(AbstractAdapter):
'binary': 'blob',
'boolean': 'boolean',
}
constants = {
constants: ClassVar[dict[str, str]] = {
'CURRENT_TIMESTAMP': 'CURRENT_TIMESTAMP',
'CURRENT_DATE': 'CURRENT_DATE',
'CURRENT_TIME': 'CURRENT_TIME',
Expand All @@ -121,7 +123,7 @@ def references_to_sql(self, column_name, value):


class PostgresAdapter(AbstractAdapter):
native_types = {
native_types: ClassVar[dict[str, str]] = {
'serial': 'serial',
'integer': 'int',
'float': 'float',
Expand All @@ -134,7 +136,7 @@ class PostgresAdapter(AbstractAdapter):
'binary': 'bytea',
'boolean': 'boolean',
}
constants = {
constants: ClassVar[dict[str, str]] = {
'CURRENT_TIMESTAMP': 'current_timestamp',
'CURRENT_DATE': 'current_date',
'CURRENT_TIME': 'current_time',
Expand All @@ -148,7 +150,7 @@ def references_to_sql(self, column_name, value):


class SQLiteAdapter(AbstractAdapter):
native_types = {
native_types: ClassVar[dict[str, str]] = {
'serial': 'integer autoincrement',
'integer': 'integer',
'float': 'float',
Expand All @@ -161,7 +163,7 @@ class SQLiteAdapter(AbstractAdapter):
'binary': 'blob',
'boolean': 'boolean',
}
constants = {
constants: ClassVar[dict[str, str]] = {
'CURRENT_TIMESTAMP': "CURRENT_TIMESTAMP",
'CURRENT_DATE': "CURRENT_DATE",
'CURRENT_TIME': "CURRENT_TIME",
Expand Down
Loading