Repository navigation
Fetch storage_id once per Repository #10586
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
Open
arielshaqed
wants to merge
9
commits into
master
Choose a base branch
from
feature/py-hl-less-get-repo
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1f91c36
Fetch storage_id once per Repository
arielshaqed db78e93
Use repo rather than repository_id in integration tests
arielshaqed a7715c5
Fix __annotations__ access
arielshaqed ab0410c
[CR] @re_arg -> @renamed_parameters
arielshaqed c932caf
[CR] Restore Object.repo, plumb repo objects into branches and tags
arielshaqed fb44f23
[CR] Restore correct name for repository(repository_id) parameter in …
arielshaqed 73fbd47
[CR] Change repository_id -> repo in ImportManager as well
arielshaqed 22aacd5
[CR] Return an exact type from renamed_parameters
arielshaqed 77e28bb
Allow code with repository_id to pass type-checking
arielshaqed 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| """ | ||
| Module for renaming kwargs | ||
|
|
||
| Based on https://stackoverflow.com/a/74564394 but does not warn. | ||
| """ | ||
|
|
||
| from collections.abc import Callable | ||
| from functools import wraps | ||
| from typing import Any, ParamSpec, TypeVar, cast | ||
|
|
||
| P = ParamSpec("P") | ||
| R = TypeVar("R") | ||
|
|
||
|
|
||
| def _rename_kwargs(kwarg_map: dict[str, str], func: Callable[P, R]) -> Callable[..., R]: | ||
| @wraps(func) | ||
| def wrapped(*args: Any, **kwargs: Any) -> R: | ||
| new_kwargs = {} | ||
| for k, v in kwargs.items(): | ||
| new_kwargs[kwarg_map.get(k, k)] = v | ||
| return cast(Callable[..., R], func)(*args, **new_kwargs) | ||
| return wrapped | ||
|
|
||
|
|
||
| def renamed_parameters(**kwarg_map: str) -> Callable[[Callable[P, R]], Callable[P, R]]: | ||
| """ | ||
| Decorator for renaming args | ||
|
|
||
| To rename old1 -> new1 and old2 -> new2, decorate the function definition: | ||
|
|
||
| @renamed_parameters(old1="new1", old2="new2") | ||
| def func(new1, new2): | ||
| pass | ||
|
|
||
| Old names keep working at runtime, but type checkers see only the new | ||
| signature, so they reject calls that use old names. | ||
|
|
||
| If old callers must type-check, declare both signatures with @overload, | ||
| mark the old one @deprecated, and decorate the implementation with | ||
| renamed_parameters_overloaded instead: | ||
|
|
||
| @overload | ||
| def func(new1, new2): ... | ||
| @overload | ||
| @deprecated("old1, old2 renamed to new1, new2") | ||
| def func(*, old1, old2): ... | ||
|
|
||
| @renamed_parameters_overloaded(old1="new1", old2="new2") | ||
| def func(new1, new2): | ||
| pass | ||
|
|
||
| Make old names keyword-only in the deprecated overload: positional calls | ||
| already match the new signature, and mixing a positional new1 with a | ||
| keyword old1 fails at runtime. Use typing_extensions.deprecated, which | ||
| supports all Python versions. | ||
|
|
||
| Type checkers report calls that match the deprecated overload only when | ||
| asked to: mypy needs --enable-error-code=deprecated, pyright needs | ||
| reportDeprecated (enabled in strict mode). | ||
| """ | ||
| def decorator(func: Callable[P, R]) -> Callable[P, R]: | ||
| return cast(Callable[P, R], _rename_kwargs(kwarg_map, func)) | ||
| return decorator | ||
|
|
||
|
|
||
| def renamed_parameters_overloaded(**kwarg_map: str) -> Callable[[Callable[P, R]], Callable[..., R]]: | ||
| """ | ||
| renamed_parameters for implementations of @overload-ed functions. | ||
|
|
||
| Identical at runtime. The decorated function accepts any arguments, so that | ||
| type checkers accept it as an implementation of the deprecated overloads that | ||
| use old names. Callers are still checked against the overloads. See | ||
| renamed_parameters for usage. | ||
| """ | ||
| def decorator(func: Callable[P, R]) -> Callable[..., R]: | ||
| return _rename_kwargs(kwarg_map, func) | ||
| return decorator |
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.
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.