-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Refactoring/mypy issues test #1017
Refactoring/mypy issues test #1017
Conversation
This reverts commit 799e755.
* test_experiment_builder_discrete_default_params * test_experiment_builder_continuous_default_params
* Seemed a bit odd that this test folder was not a package like all test packages.
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #1017 +/- ##
=======================================
Coverage 88.24% 88.24%
=======================================
Files 98 99 +1
Lines 8083 8144 +61
=======================================
+ Hits 7133 7187 +54
- Misses 950 957 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.40 to 3.1.41. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/gitpython-developers/GitPython/releases">gitpython's releases</a>.</em></p> <blockquote> <h2>3.1.41 - fix Windows security issue</h2> <p>The details about the Windows security issue <a href="https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-2mqj-m65w-jghx">can be found in this advisory</a>.</p> <p>Special thanks go to <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> who reported the issue and fixed it in a single stroke, while being responsible for an incredible amount of improvements that he contributed over the last couple of months ❤️.</p> <h2>What's Changed</h2> <ul> <li>Add <code>__all__</code> in git.exc by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1719">gitpython-developers/GitPython#1719</a></li> <li>Set submodule update cadence to weekly by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1721">gitpython-developers/GitPython#1721</a></li> <li>Never modify sys.path by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1720">gitpython-developers/GitPython#1720</a></li> <li>Bump git/ext/gitdb from <code>8ec2390</code> to <code>ec58b7e</code> by <a href="https://github.com/dependabot"><code>@dependabot</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1722">gitpython-developers/GitPython#1722</a></li> <li>Revise comments, docstrings, some messages, and a bit of code by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1725">gitpython-developers/GitPython#1725</a></li> <li>Use zero-argument super() by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1726">gitpython-developers/GitPython#1726</a></li> <li>Remove obsolete note in _iter_packed_refs by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1727">gitpython-developers/GitPython#1727</a></li> <li>Reorganize test_util and make xfail marks precise by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1729">gitpython-developers/GitPython#1729</a></li> <li>Clarify license and make module top comments more consistent by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1730">gitpython-developers/GitPython#1730</a></li> <li>Deprecate compat.is_<!-- raw HTML omitted -->, rewriting all uses by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1732">gitpython-developers/GitPython#1732</a></li> <li>Revise and restore some module docstrings by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1735">gitpython-developers/GitPython#1735</a></li> <li>Make the rmtree callback Windows-only by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1739">gitpython-developers/GitPython#1739</a></li> <li>List all non-passing tests in test summaries by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1740">gitpython-developers/GitPython#1740</a></li> <li>Document some minor subtleties in test_util.py by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1749">gitpython-developers/GitPython#1749</a></li> <li>Always read metadata files as UTF-8 in setup.py by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1748">gitpython-developers/GitPython#1748</a></li> <li>Test native Windows on CI by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1745">gitpython-developers/GitPython#1745</a></li> <li>Test macOS on CI by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1752">gitpython-developers/GitPython#1752</a></li> <li>Let close_fds be True on all platforms by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1753">gitpython-developers/GitPython#1753</a></li> <li>Fix IndexFile.from_tree on Windows by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1751">gitpython-developers/GitPython#1751</a></li> <li>Remove unused TASKKILL fallback in AutoInterrupt by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1754">gitpython-developers/GitPython#1754</a></li> <li>Don't return with operand when conceptually void by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1755">gitpython-developers/GitPython#1755</a></li> <li>Group .gitignore entries by purpose by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1758">gitpython-developers/GitPython#1758</a></li> <li>Adding dubious ownership handling by <a href="https://github.com/marioaag"><code>@marioaag</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1746">gitpython-developers/GitPython#1746</a></li> <li>Avoid brittle assumptions about preexisting temporary files in tests by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1759">gitpython-developers/GitPython#1759</a></li> <li>Overhaul noqa directives by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1760">gitpython-developers/GitPython#1760</a></li> <li>Clarify some Git.execute kill_after_timeout limitations by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1761">gitpython-developers/GitPython#1761</a></li> <li>Bump actions/setup-python from 4 to 5 by <a href="https://github.com/dependabot"><code>@dependabot</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1763">gitpython-developers/GitPython#1763</a></li> <li>Don't install black on Cygwin by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1766">gitpython-developers/GitPython#1766</a></li> <li>Extract all "import gc" to module level by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1765">gitpython-developers/GitPython#1765</a></li> <li>Extract remaining local "import gc" to module level by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1768">gitpython-developers/GitPython#1768</a></li> <li>Replace xfail with gc.collect in TestSubmodule.test_rename by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1767">gitpython-developers/GitPython#1767</a></li> <li>Enable CodeQL by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1769">gitpython-developers/GitPython#1769</a></li> <li>Replace some uses of the deprecated mktemp function by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1770">gitpython-developers/GitPython#1770</a></li> <li>Bump github/codeql-action from 2 to 3 by <a href="https://github.com/dependabot"><code>@dependabot</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1773">gitpython-developers/GitPython#1773</a></li> <li>Run some Windows environment variable tests only on Windows by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1774">gitpython-developers/GitPython#1774</a></li> <li>Fix TemporaryFileSwap regression where file_path could not be Path by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1776">gitpython-developers/GitPython#1776</a></li> <li>Improve hooks tests by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1777">gitpython-developers/GitPython#1777</a></li> <li>Fix if items of Index is of type PathLike by <a href="https://github.com/stegm"><code>@stegm</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1778">gitpython-developers/GitPython#1778</a></li> <li>Better document IterableObj.iter_items and improve some subclasses by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1780">gitpython-developers/GitPython#1780</a></li> <li>Revert "Don't install black on Cygwin" by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1783">gitpython-developers/GitPython#1783</a></li> <li>Add missing pip in $PATH on Cygwin CI by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1784">gitpython-developers/GitPython#1784</a></li> <li>Shorten Iterable docstrings and put IterableObj first by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1785">gitpython-developers/GitPython#1785</a></li> <li>Fix incompletely revised Iterable/IterableObj docstrings by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1786">gitpython-developers/GitPython#1786</a></li> <li>Pre-deprecate setting Git.USE_SHELL by <a href="https://github.com/EliahKagan"><code>@EliahKagan</code></a> in <a href="https://redirect.github.com/gitpython-developers/GitPython/pull/1782">gitpython-developers/GitPython#1782</a></li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/gitpython-developers/GitPython/commit/f28873828496a6632b3a99101e3582ad164e9bb9"><code>f288738</code></a> bump patch level</li> <li><a href="https://github.com/gitpython-developers/GitPython/commit/ef3192cc414f2fd9978908454f6fd95243784c7f"><code>ef3192c</code></a> Merge pull request <a href="https://redirect.github.com/gitpython-developers/GitPython/issues/1792">#1792</a> from EliahKagan/popen</li> <li><a href="https://github.com/gitpython-developers/GitPython/commit/1f3caa31f1b63908235e341418a0804ed37a320a"><code>1f3caa3</code></a> Further clarify comment in test_hook_uses_shell_not_from_cwd</li> <li><a href="https://github.com/gitpython-developers/GitPython/commit/3eb7c2ab82e6dbe101ff916fca29d539cc2793af"><code>3eb7c2a</code></a> Move safer_popen from git.util to git.cmd</li> <li><a href="https://github.com/gitpython-developers/GitPython/commit/c551e916c7b9e2d623b9d76f3352849a707d9bbe"><code>c551e91</code></a> Extract shared logic for using Popen safely on Windows</li> <li><a href="https://github.com/gitpython-developers/GitPython/commit/15ebb258d4eebd9bf0f38780570d57e0b968b8de"><code>15ebb25</code></a> Clarify comment in test_hook_uses_shell_not_from_cwd</li> <li><a href="https://github.com/gitpython-developers/GitPython/commit/f44524a9a9c8122b9b98d6e5797e1dfc3211c0b7"><code>f44524a</code></a> Avoid spurious "location may have moved" on Windows</li> <li><a href="https://github.com/gitpython-developers/GitPython/commit/a42ea0a38c489caf9969836141120d760d3754b4"><code>a42ea0a</code></a> Cover absent/no-distro bash.exe in hooks "not from cwd" test</li> <li><a href="https://github.com/gitpython-developers/GitPython/commit/7751436b94d96ce0978b301681b851edd6efed63"><code>7751436</code></a> Extract venv management from test_installation</li> <li><a href="https://github.com/gitpython-developers/GitPython/commit/66ff4c177accfb4f21d3eb476381d248d99fd8b5"><code>66ff4c1</code></a> Omit CWD in search for bash.exe to run hooks on Windows</li> <li>Additional commits viewable in <a href="https://github.com/gitpython-developers/GitPython/compare/3.1.40...3.1.41">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=gitpython&package-manager=pip&previous-version=3.1.40&new-version=3.1.41)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/thu-ml/tianshou/network/alerts). </details> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Is this ready for review? If yes, then pls include the tests directory into the poe task (inside pyproject.toml) and make sure CI is green |
Noted. Re: status, not ready for review yet. I think I can finish resolving the issues in the test by the end of this weekend. |
Great, I'm marking it as draft until then. Mark it as ready and assign me once you're done please |
There's been some changes on master now. They likely won't affect the tests (they do affect examples though) but it would still be better to merge master into your branch before continuing. |
Issue 1:Fixing [attr-defined] for different types of spaces. Here is one example:
that gives this error:
Solution 1: Check for the
I am only checking for Solution 2: Tell mypy to ignore the [attr-defined] error in these cases. OutcomeI prefer Solution 1 or something similar to it. What do you think? Issue 2:The issue above repeats itself in different test files. It would be better to move the solution implementation in a |
I also prefer solution 1, and feel free to write small util functions for extracting such info from an unknown space into the source code to reduce duplication. I'm not supper happy that something called |
* use SpaceInfo to type env attributes * catch case when env.spec None * add type annotations to policy * add type annotations to funcs
* use SpaceInfo to type env attributes * catch case when env.spec None * add type annotations to policy, buffer
* use SpaceInfo to type env attributes * catch case when env.spec None * add type annotations to policy, actor, critic
* use SpaceInfo to type env attributes * catch case when env.spec None * add type annotations to policy
* use SpaceInfo to type env attributes * catch case when env.spec None * add type annotations to policy
* use SpaceInfo to type env attributes * catch case when env.spec None * add type annotations to policy
Let me know when you're done and the additional checks have been included in CI, then I'd have a final look and we can merge it |
Yep, for sure! I'll let you know once it's ready for review or some additional thing needs a closer look from your side. I'm working on the updates using SpaceInfo at the moment. |
* use SpaceInfo to type env attributes * catch case when env.spec None * add type annotations to policy
* use SpaceInfo to type env attributes * catch case when env.spec None * add type annotations to policy, buffer
I'll have a big update coming today (will ping again here), that we should consider for review toward closing this PR. We can solve any remaining mypy issues (not too many left) in a new PR. |
I just opened the other PR running mypy on notebooks #1041. Checking your changes I don't think this should affect you, but it might rather resolve some more mypy errors. |
* use SpaceInfo to type env attributes * add type annotations to policy, buffer, and other funcs * Cover case env.spec = None and env.spec.reward_threshold = None
* ensures that trainer can leverage policy-specific features
* A (dedicated) StringMixin will be used to improve repr of `CollectStats` (see: thu-ml#1017 (comment))
* If we are sure that `dist` won't output a different distribution than `Independent` than we can switch to it, otherwise I'd keep the more flexible `Distribution` type.
* Use a common `LoggerFactoryDefault` object
* I used the Union of replay buffer types for clarity * Alternative would be to use the most general common ancestor `ReplayBuffer` only
* Expected "Callable[[], None] for logging.run_cli(main)
I pushed now the changes for review. I didn't add examples and test dir to The PR is quite big already, and I thought we could maybe close this one now after the review. Then I can solve the other issues in a second PR. |
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.
Thanks a lot for this work! Sorry for my delayed reaction, I was on vacation till today. Merging this now, and looking forward to the follow-up that will close the remaining mypy issues
Note: at many places there is something like policy: GailPolicy = GailPolicy(...)
. I don't think this is required, am I wrong?
Improves typing in examples and tests, towards mypy passing there.
Introduces the
SpaceInfo
utility