Skip to content

Commit

Permalink
chore: relax flask dependency constraint (#203)
Browse files Browse the repository at this point in the history
* chore: relax flask dependency constraint

Why
===
* Flask released a 3.0.0 version, which we couldn't support because of
our version bounds. The changelog
https://flask.palletsprojects.com/en/3.0.x/changes/ looks innocuous
for our purposes

What changed
===
* Changed pyproject.toml to use >=2.0.0 instead of ^2.0.0
* nix run nixpkgs#poetry -- lock --no-update

Test plan
===
* try installing this verison in a repl after it is released
* nix run nixpkgs#poetry -- check --lock

* Hosted repl -> deployments

* New location for repl-auth.js

* Adding deprecation warnings to id_co_url/co_url

* Unify database-test-jwt-py with the new implementation

Old version has different semantics and is compatible with new version
anyway

* Adding a RIDT test for non-async Database

* Clarify "PASSWORD" was actually "JWT_PASSWORD" this whole time

---------

Co-authored-by: Devon Stewart <[email protected]>
  • Loading branch information
ryantm and blast-hardcheese authored Jan 17, 2024
1 parent eaf83a5 commit 3cee3df
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[flake8]
select = ANN,B,B9,BLK,C,D,DAR,E,F,I,S,W
ignore = E203,W503,ANN101,ANN102,S322,ANN206,S201,D105,D107,ANN401
ignore = E203,E501,W503,ANN101,ANN102,S322,ANN206,S201,D105,D107,ANN401
per-file-ignores =
src/replit/__init__.py:F401
src/replit/web/__init__.py:F401
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ documentation = "https://replit-py.readthedocs.org/"
[tool.poetry.dependencies]
python = ">=3.9,<4.0"
typing_extensions = "^4"
Flask = "^2.0.0"
Flask = ">=2.0.0"
Werkzeug = ">=2,<4"
aiohttp = "^3.6.2"
requests = "^2.25.1"
Expand Down
8 changes: 8 additions & 0 deletions src/replit/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import os
from typing import Optional

from typing_extensions import deprecated


class ReplInfo:
"""Represents info about the current repl."""
Expand Down Expand Up @@ -33,6 +35,9 @@ def language(self) -> Optional[str]:
return os.getenv("REPL_LANGUAGE")

@property
@deprecated(
"Deprecated, please see https://blog.replit.com/hosting-changes for more details"
)
def id_co_url(self) -> Optional[str]:
"""The hosted URL of the repl in the form https://<id>.id.repl.co.
Expand All @@ -48,6 +53,9 @@ def id_co_url(self) -> Optional[str]:
return f"https://{repl_id}.id.repl.co"

@property
@deprecated(
"Deprecated, please see https://blog.replit.com/hosting-changes for more details"
)
def co_url(self) -> Optional[str]:
"""The readable, hosted repl.co URL for this repl.
Expand Down
2 changes: 1 addition & 1 deletion src/replit/web/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

authentication_snippet = (
'<script authed="location.reload()" '
'src="https://auth.turbio.repl.co/script.js"></script>'
'src="https://replit.com/public/js/repl-auth.js"></script>'
)


Expand Down
17 changes: 12 additions & 5 deletions tests/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ async def asyncSetUp(self) -> None:
elif "DB_RIDT" in os.environ:
password = os.environ["RIDT_PASSWORD"]
req = requests.get(
"https://database-test-ridt.util.repl.co", auth=("test", password)
"https://database-test-ridt-util.replit.app", auth=("test", password)
)
url = req.text
self.db = AsyncDatabase(url)
else:
password = os.environ["PASSWORD"]
password = os.environ["JWT_PASSWORD"]
req = requests.get(
"https://database-test-jwt.util.repl.co", auth=("test", password)
"https://database-test-jwt-util.replit.app", auth=("test", password)
)
url = req.text
self.db = AsyncDatabase(url)
Expand Down Expand Up @@ -133,10 +133,17 @@ def setUp(self) -> None:
"""Grab a JWT for all the tests to share."""
if "REPLIT_DB_URL" in os.environ:
self.db = Database(os.environ["REPLIT_DB_URL"])
elif "DB_RIDT" in os.environ:
password = os.environ["RIDT_PASSWORD"]
req = requests.get(
"https://database-test-ridt-util.replit.app", auth=("test", password)
)
url = req.text
self.db = Database(url)
else:
password = os.environ["PASSWORD"]
password = os.environ["JWT_PASSWORD"]
req = requests.get(
"https://database-test-jwt.kochman.repl.co", auth=("test", password)
"https://database-test-jwt-util.replit.app", auth=("test", password)
)
url = req.text
self.db = Database(url)
Expand Down

0 comments on commit 3cee3df

Please sign in to comment.