-
-
Notifications
You must be signed in to change notification settings - Fork 324
Move reactpy.backend.hooks
module into reactpy.core.hooks
#1210
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
Merged
Archmonger
merged 16 commits into
reactive-python:main
from
joshbmair:move-backend-hooks
Oct 29, 2024
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7b0bfb8
Remove `reactpy.backend.hooks` module
joshbmair 36ca352
Add 'reactpy.backend.hooks -> reactpy.core.hooks' move to changelog
joshbmair 942ad6a
Move use_connection to sit next to functions that use them
joshbmair 4f5b780
Re-add 'reactpy.backend.hooks' with deprecation warnings
joshbmair 908206c
Add reactpy.backend.hooks deprecation in changelog, and fix mistakes
joshbmair f503824
Add formatting to module names
joshbmair 51cd038
Fix formatting
joshbmair 8967f7f
Add nocov comments to backend.hooks
joshbmair a7327c4
Merge branch 'main' into move-backend-hooks
Archmonger 8b071a5
Fix deprecation warning messages
joshbmair 45d3770
Pin mypy to v1.8
Archmonger 27a06a8
conditional pkg_resources
Archmonger fea5e23
Remove reactpy-flake8
Archmonger a9ba5db
Revert
Archmonger eb48779
Merge remote-tracking branch 'upstream/main' into pr/1210
Archmonger 59bc0e1
Merge branch 'main' into move-backend-hooks
Archmonger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,45 @@ | ||
from __future__ import annotations | ||
from __future__ import annotations # nocov | ||
|
||
from collections.abc import MutableMapping | ||
from typing import Any | ||
from collections.abc import MutableMapping # nocov | ||
from typing import Any # nocov | ||
|
||
from reactpy.backend.types import Connection, Location | ||
from reactpy.core.hooks import create_context, use_context | ||
from reactpy.core.types import Context | ||
from reactpy._warnings import warn # nocov | ||
from reactpy.backend.types import Connection, Location # nocov | ||
from reactpy.core.hooks import ConnectionContext, use_context # nocov | ||
|
||
# backend implementations should establish this context at the root of an app | ||
ConnectionContext: Context[Connection[Any] | None] = create_context(None) | ||
|
||
|
||
def use_connection() -> Connection[Any]: | ||
def use_connection() -> Connection[Any]: # nocov | ||
"""Get the current :class:`~reactpy.backend.types.Connection`.""" | ||
warn( | ||
"The module reactpy.backend.hooks has been deprecated and will be deleted in the future. ", | ||
"Call reactpy.use_connection instead.", | ||
DeprecationWarning, | ||
) | ||
|
||
conn = use_context(ConnectionContext) | ||
if conn is None: # nocov | ||
if conn is None: | ||
msg = "No backend established a connection." | ||
raise RuntimeError(msg) | ||
return conn | ||
|
||
|
||
def use_scope() -> MutableMapping[str, Any]: | ||
def use_scope() -> MutableMapping[str, Any]: # nocov | ||
"""Get the current :class:`~reactpy.backend.types.Connection`'s scope.""" | ||
warn( | ||
"The module reactpy.backend.hooks has been deprecated and will be deleted in the future. ", | ||
"Call reactpy.use_scope instead.", | ||
DeprecationWarning, | ||
) | ||
|
||
return use_connection().scope | ||
|
||
|
||
def use_location() -> Location: | ||
def use_location() -> Location: # nocov | ||
"""Get the current :class:`~reactpy.backend.types.Connection`'s location.""" | ||
warn( | ||
"The module reactpy.backend.hooks has been deprecated and will be deleted in the future. ", | ||
"Call reactpy.use_location instead.", | ||
DeprecationWarning, | ||
) | ||
|
||
return use_connection().location |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.