I tried copying the .replit, replit.nix, pyproject.toml, poetry.lock, .pythonlibs/lib/python3.10/site-packages/replit/database/database.py, and .pythonlibs/lib/python3.10/site-packages/replit/__init__.py
files from one of the 100 days of code repls, into the “new repl”
But then when I run the code I get this TypeError: 'ABCMeta' object is not subscriptable
TypeError
File "/home/runner/MealyFrequentDeveloper/.pythonlibs/lib/python3.10/site-packages/replit/__init__.py", line 7, in <module>
from . import database, web
File "/home/runner/MealyFrequentDeveloper/.pythonlibs/lib/python3.10/site-packages/replit/database/__init__.py", line 4, in <module>
from . import default_db
File "/home/runner/MealyFrequentDeveloper/.pythonlibs/lib/python3.10/site-packages/replit/database/default_db.py", line 6, in <module>
from .database import Database
File "/home/runner/MealyFrequentDeveloper/.pythonlibs/lib/python3.10/site-packages/replit/database/database.py", line 449, in <module>
class Database(abc.MutableMapping):
File "/home/runner/MealyFrequentDeveloper/.pythonlibs/lib/python3.10/site-packages/replit/database/database.py", line 643, in Database
def keys(self) -> abc.KeysView[str]:
TypeError: 'ABCMeta' object is not subscriptable
When I try the AI’s suggestion :
Change line 214 in database.py
from:
def keys(self) -> abc.KeysView[str]:
to:
def keys(self) -> abc.KeysView:
JSONDecodeError
password ?abc123
Traceback (most recent call last):
File "main.py", line 19, in <module>
checksalt = db["password"]["salt"]
File "/home/runner/MealyFrequentDeveloper/.pythonlibs/lib/python3.10/site-packages/replit/database/database.py", line 530, in __getitem__
val = json.loads(raw_val)
File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
It tells me to try using ayncio
in main.py
and to Modify line 531 in the database.py file from:
val = json.loads(raw_val)
to:
if raw_val:
val = json.loads(raw_val)
else:
val = None # Handle the case where raw_val is empty or not valid JSON
And here I’m stuck now. Feels like I’m going in circles.
I marked @JustCoding123 's post as the solution because I think it was the closest to my initial question of why hash()
works consistently in the 100 d.o.c. repls but not the other one and helped me understand the most, but everyone was helpful and I feel like I’ve learned from all of it. Thank you everyone.