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 — Start adding types to Submodule, add py.typed to manifest by Yobmod · Pull Request #1282 · gitpython-developers/GitPython

Conversation

@Yobmod

@Yobmod Yobmod commented Jun 30, 2021 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Started to add types to Submodule

Removed include_package_data() from setup and added py.typed to MANIFEST.INI instead (this is what mypy package does, but not what the mypy instructions say!)

Improve types for .traverse() with TypeVar and overloads, create TraversableIterableObj class to reduce code duplication from overloads.

Add some more checks to test_commit.test_traverse()

Sorry, something went wrong.

Uh oh!

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

All reactions
Yobmod and others added 9 commits June 30, 2021 18:39
@Yobmod
move py.typed from setup.py to MANIFEST.INI
75dbf90
@Yobmod
Type Traversable.traverse() better, start types of submodule
82b131c
@Yobmod
rmv github squashed commit file
b7fe37a
@Yobmod
Type Tree.traverse() better
237966a
@Yobmod
Type Traversable/list_traverse() better, make IterablleObj a protocol
a8ddf69
@Yobmod
Fix forward ref
1b69965
@Yobmod
Put protocol behind py version check
5266521
@Yobmod
Flake 8 fix
8fd5414
@Byron
Merge branch 'main' into Yobmod/main
e5f2528
Byron
Byron requested changes Jul 1, 2021
View reviewed changes

@Byron Byron left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's great work, thanks a lot!

It's good to see that people are already starting to use it, too.

Can't wait to merge.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread git/objects/submodule/base.py Resolved

Uh oh!

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

Comment thread setup.py Resolved

Uh oh!

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

Yobmod added 3 commits July 1, 2021 10:35
@Yobmod
Add missed types to Commit, uncomment to_native_path_linux()
02b8ef0
@Yobmod
Merge branch 'main' of https://github.com/Yobmod/gitpython
da7c4aa
@Yobmod
Make Commit.message bytes | str
d4a9eab
@Byron
Byron merged commit 18c777b into gitpython-developers:main Jul 1, 2021
@Byron

Byron commented Jul 2, 2021

Copy link
Copy Markdown
Member

Thanks a million for all your work!
It's clear you are committed to getting this done and I would be glad if you would want to become a maintainer. Now that types have been added and it feels like the project would be in serious trouble without your continued support in keeping maintaining types as python evolves along with the type checkers.
Thanks a lot for your consideration.

All reactions

Sorry, something went wrong.

Uh oh!

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

@Byron Byron added this to the v3.1.19 - Bugfixes milestone Jul 23, 2021
EliahKagan added a commit to EliahKagan/GitPython that referenced this pull request Dec 22, 2023
@EliahKagan
Expand "invalid hash" test to assert normal StopIteration
822846a
Returning an explicit value from a generator function causes that
value to be bound to the `value` attribute of the StopIteration
exception. This is available as the result of "yield from" when it
is used as an expression; or by explicitly catching StopIteration,
binding the StopIteration exception to a variable, and accessing
the attribute. This feature of generators is rarely used.

The `return iter([])` statement in Submodule.iter_items uses this
feature, causing the resulting StopIteration exception object to
have a `value` attribute that refers to a separate second iterator
that also yields no values. From context, this behavior is clearly
not the goal; a bare return statement should be used here (which
has the same effect except for the `value` attribute of the
StopIteration exception). The code had used a bare return prior to
82b131c (gitpython-developers#1282), when `return` was changed to `return iter([])`.
That was part of a change that added numerous type annotations. It
looks like it was either a mistake, or possibly an attempt to work
around an old bug in a static type checker.

This commit extends the test_iter_items_from_invalid_hash test to
assert that the `value` attribute of the StopIteration is its usual
default value of None. This commit only extends the test; it does
not fix the bug.
EliahKagan added a commit to EliahKagan/GitPython that referenced this pull request Dec 22, 2023
@EliahKagan
Expand "invalid hash" test to assert normal StopIteration
b9aa1ff
Returning an explicit value from a generator function causes that
value to be bound to the `value` attribute of the StopIteration
exception. This is available as the result of "yield from" when it
is used as an expression; or by explicitly catching StopIteration,
binding the StopIteration exception to a variable, and accessing
the attribute. This feature of generators is rarely used.

The `return iter([])` statement in Submodule.iter_items uses this
feature, causing the resulting StopIteration exception object to
have a `value` attribute that refers to a separate second iterator
that also yields no values. From context, this behavior is clearly
not the goal; a bare return statement should be used here (which
has the same effect except for the `value` attribute of the
StopIteration exception). The code had used a bare return prior to
82b131c (gitpython-developers#1282), when `return` was changed to `return iter([])`.
That was part of a change that added numerous type annotations. It
looks like it was either a mistake, or possibly an attempt to work
around an old bug in a static type checker.

This commit extends the test_iter_items_from_invalid_hash test to
assert that the `value` attribute of the StopIteration is its usual
default value of None. This commit only extends the test; it does
not fix the bug.
@EliahKagan EliahKagan mentioned this pull request Dec 22, 2023
Submodule.iter_items sometimes attaches second empty iterator to its StopIteration #1779
Closed
EliahKagan added a commit to EliahKagan/GitPython that referenced this pull request Dec 22, 2023
@EliahKagan
Expand "invalid hash" test to assert normal StopIteration
f5dc1c4
Returning an explicit value from a generator function causes that
value to be bound to the `value` attribute of the StopIteration
exception. This is available as the result of "yield from" when it
is used as an expression; or by explicitly catching StopIteration,
binding the StopIteration exception to a variable, and accessing
the attribute. This feature of generators is rarely used.

The `return iter([])` statement in Submodule.iter_items uses this
feature, causing the resulting StopIteration exception object to
have a `value` attribute that refers to a separate second iterator
that also yields no values (gitpython-developers#1779).

From context, this behavior is clearly not the goal; a bare return
statement should be used here (which has the same effect except for
the `value` attribute of the StopIteration exception). The code had
used a bare return prior to 82b131c (gitpython-developers#1282), when `return` was
changed to `return iter([])`. That was part of a change that added
numerous type annotations. It looks like it was either a mistake,
or possibly an attempt to work around an old bug in a static type
checker.

This commit extends the test_iter_items_from_invalid_hash test to
assert that the `value` attribute of the StopIteration is its usual
default value of None. This commit only extends the test; it does
not fix the bug.
@EliahKagan EliahKagan mentioned this pull request Mar 4, 2024
Commit_ish is much broader than commit-ish #1858
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Byron Byron Byron requested changes

Uh oh!

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

Assignees

No one assigned

Labels

None yet

Milestone

v3.1.19 - Bugfixes

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.