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

type hint and example out-of-sync #1521

Open
castedo opened this issue Mar 23, 2025 · 5 comments
Open

type hint and example out-of-sync #1521

castedo opened this issue Mar 23, 2025 · 5 comments

Comments

@castedo
Copy link
Contributor

castedo commented Mar 23, 2025

The target parameter of the GitClient.fetch method is Repo:

target: Repo,

and porcelain.fetch calls the above function with the repo parameter of porcelain.fetch

fetch_result = client.fetch(path, r, progress=errstream.write, depth=depth)

(via open_repo_closing which in this case is a no-op passthrough).

But the examples/memoryrepo.py is using a MemoryRepo argument for the target parameter:

fetch_result = porcelain.fetch(local_repo, sys.argv[1])

but MemoryRepo is not a subclass of Repo, only a BaseRepo. So this MemoryRepo object will get passed down into target which is typed to a Repo.

Not sure if this is an issue with the type hint or whether the example is showing something that sometimes fails at runtime.

Is it safe to use a MemoryRepo with GitClient.fetch?

@castedo
Copy link
Contributor Author

castedo commented Mar 23, 2025

Hmmmm, sorry I've messed up my description or I'm confused. I'm going to close this and then re-open if I find something real.

@castedo castedo closed this as completed Mar 23, 2025
@castedo
Copy link
Contributor Author

castedo commented Mar 23, 2025

OK, I've updated the description of this issue to include a missing step. Sorry about the confusion.

I'm mainly just wondering if MemoryRepo is safe to use with GitClient.fetch.

And this might also be a type hint that needs updating.

@castedo castedo reopened this Mar 23, 2025
@jelmer
Copy link
Owner

jelmer commented Mar 23, 2025

It should be safe to use MemoryRepo with GitClient.fetch, and the typehint should just be updated.

I don't think we have any explicit tests today that try to use GitClient.fetch with MemoryRepo though.

@jelmer
Copy link
Owner

jelmer commented Mar 23, 2025

Can you send a PR to fix the type hint?

@castedo
Copy link
Contributor Author

castedo commented Mar 24, 2025

Can you send a PR to fix the type hint?

OK, sounds good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants