GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add types to git/config.py by Yobmod · Pull Request #1234 · gitpython-developers/GitPython

Conversation

@Yobmod

@Yobmod Yobmod commented May 12, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Adding types to config.py and cmd.py
Functions annotated all listed in commit titles.

I had to use a few casts in this one, due to the use of hassattr to distinguish strings from file objects.
If anyone knows a better way, let me know. (Its an open issue on mypy, and Guido recomends rewriting and doing type checks - a job for the future!) python/mypy#1424 (comment)

Some minor logic changes, all for type checks (e.g. because str is a subtype of Sequence, have to check for it before other sequences) or to try to separate strings from bytes.

All check pass and mypy happy. I also ran some basic scripts against it, and no errors.

Might be worth cutting a release after this PR, in case an errors are hiding?
(No rush, I only submitted this one so fast as it was waiting in my fork already)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Byron reacted with rocket emoji
All reactions
  • 🚀 1 reaction
Yobmod added 14 commits May 8, 2021 20:28
@Yobmod
Add types to config.py CONFIG_LEVELS, MetaParserBuilder.__new__() .ne…
efe6833
…eds_values() .set_dirty_and_flush_changes()
@Yobmod
Add types to config.py class SectionConstraint
6e331a0
@Yobmod
Add types to config.py class _OMD
e21d96a
@Yobmod
Add types to config.py GitConfigParser .__init__() .aquire_lock()
efc2598
@Yobmod
Add types to config.py GitConfigParser .release() ._read() ._has_incl…
94b7ece
…udes() ._included_paths() .__del__() .__exit__() .__enter__() ._optionform()
@Yobmod
Add types to config.py GitConfigParser .read()
c6e458c
@Yobmod
Add types to config.py GitConfigParser .write() ._write() .items() .i…
ab69b9a
…tems_all()
@Yobmod
Add types to config.py GitConfigParser ._assure_writable .add_section…
c2f9f4e
… .read_only .get_value .get_values ._string_to_value ._value_to_string .add_value .rename_section
@Yobmod
Add typing section to cmd.py
3473060
@Yobmod
Add types to cmd.py Git
887f249
@Yobmod
Add types to cmd.py AutoInterrupt
f1ace25
@Yobmod
Add types to cmd.py CatFileContentStream
39eb0e6
@Yobmod
Add types to cmd.py Git
f62c8d8
@Yobmod
flake8 and mypy fixes
96c4365
@Byron

Byron commented May 13, 2021

Copy link
Copy Markdown
Member

Thanks for the additional explanation - it definitely helps. My workflow is to checkout the PR and try the types locally, possibly changing some types to see what mypy thinks about that just to realize that the types presented here are the one (or only) way to make it happy.

In the very first file fo the diff safe_decode also can be called with None which is strange to see, but currently required due to call sites not properly checking what they try to decode. Very interesting, and a lot of potential for future improvements.

Maybe I can also direct your attention to #1235 in case there is a chance it might be related to typing.

In any case, I will cut a release momentarily.

And last but not least: Thank you for all the work you put into GitPython types! They should help making the codebase more maintainable.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Byron
Byron merged commit 96c4365 into gitpython-developers:main May 13, 2021
@EliahKagan EliahKagan mentioned this pull request Dec 26, 2023
In handle_process_output don't forward finalizer result #1788
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Yobmod @Byron
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.