Skip to content

Add type hints #6

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

Conversation

tlaferriere
Copy link

@tlaferriere tlaferriere commented Oct 21, 2020

This is the conflict free version of python-semver#265. Should fix python-semver#213.

@tlaferriere tlaferriere changed the title Add type hints to the code base Add type hints Oct 21, 2020
@tlaferriere tlaferriere marked this pull request as ready for review October 22, 2020 01:12
@tlaferriere
Copy link
Author

@tomschr feel free to cherry-pick commit d9394af into the alpha branch since it contains only a trivial config change

@tomschr
Copy link
Owner

tomschr commented Oct 22, 2020

@tlaferriere Thanks Thomas, much appreciated! 👍

I've adapted the wording a bit and pushed it now to the branch. Anything else that I should integrate? Or are you still working on the typing?

@tomschr tomschr force-pushed the feature/3.0.0-alpha0 branch 2 times, most recently from b8f88f6 to c94e72a Compare October 22, 2020 20:39
tomschr and others added 6 commits October 22, 2020 22:47
* Remove targets py27, py34, py35, and pypy from `tox.ini`
* Update `README.rst` and remove anything related to Python2
  Mention maintenance branch `maint/v2`
* `setup.py`
  - Update Trove classifiers
  - Require now Python >=3.6.*
  - Remove Tox and Clean classes, try to make it
    as simple as possible
  - Extract metadata directly from source (affects all the __version__,
    __author__ etc. variables)
* `setup.cfg`
  - Add pycodestyle section
* `semver.py`
  - Change version number to "3.0.0-alpha0"
  - Remove old code related to Python2
  - Adjust Python2 vs. Python3 str/bytes
  - Add wheel as another test requirement
* `tox.ini`
  - Remove py27, py34, and py35 (out of maintenance)
  - Add docs to default testenv
  - Remove --universal from bdist_wheel
* Split test suite into separate files under tests/ dir
* Travis: Remove old versions, integrate new
  - Remove 2.7, 3.4, 3.5, and pypy
  - Integrate 3.8, 3.9-dev and nightly builds
  - Allow nightly to fail
* Add .editorconfig to have a consistent editor setup

Co-authored-by: Thomas Laferriere <t.laferriere@hotmail.ca>
Completely revamp file. Mostly update from
gh://github/gitignore/ and integrate:

* Python
* Global/Kate
* Global/Vim
* Global/VisualStudio
* Global/JetBrains
* Remove Python2
* Use Roboto font family
  Sans: Roboto (for text)
  "Serif": Roboto Slab (for headings)
  Monospace: Roboto Mono (for code)
* Improve CSS navigation
* Create new logo and move it to docs/_static
* Add new section about how to get the version of semver
* Use a more general term (2.x.y) instead of specific versions
* Number sections
* Rework deps for doc build
* Rework release procedure
* Add `changelog.d/.gitignore` to keep this directory
* Create `changelog.d/README.rst` with some descriptions
* Add `changelog.d/_template.rst` as Towncrier template
* Add `[tool.towncrier]` section in pyproject.toml
* Add "changelog" target into `tox.ini`. Use it like "tox -e changes -- CMD"
  whereas CMD is a towncrier command. The default "tox -e changes"
  calls towncrier to create a draft of the changelog file and
  output it to stdout.
* Update documentation and add include a new section "Changelog"
  included from `changelog.d/README.rst`
* Update changelog.d directory and add new files
@tomschr tomschr force-pushed the feature/3.0.0-alpha0 branch from c94e72a to e804eed Compare October 22, 2020 20:59
@tlaferriere
Copy link
Author

Actually I just wanted your opinion on it. I'm fairly certain that I've typed everything that could be typed, but I wonder if it is just too convoluted in some places ( see the aliases). Also maybe check it for any mistakes.

There are also some changes to the Travis file, but I can't really test those locally.

Mypy passes btw.

@tlaferriere
Copy link
Author

You might want to consider cherry-picking 10c2173 too, because I changed the types of the changelog files.

Generally, remove everything related to Python 2.7 & 3.4 and
add missing 3.8 & 3.9:

* Raise version to 2.99.99 (to indicate that it's different from 2.10.0)
* Prepare (empty) CHANGELOG for 2.99.99
* Correct Trove categories and python_requires in setup.py
* Adapt tox.ini & .travis.yml: remove old stuff, add missing (see above)
* Adapt semver.py
  - Remove if clause for cmp
  - Don't check for `__name__`, use `__qualname__` instead
  - Use yield from ... (for loop is not necessary anymore)
This makes it possible to distinguish between version 2
and version 3. For example, >=2.8,<3
@tlaferriere tlaferriere force-pushed the 213-type-hint-from-prep-py3 branch from 10c2173 to 9808da4 Compare October 23, 2020 03:22
tlaferriere and others added 6 commits October 22, 2020 23:29
Add changelog for the type hints issue

Make mypy pass and try adding it to travis.yml

Run black

Remove unnecessary and overly complicated type alias

Add beautiful type aliases

Configure tox to run mypy check

First try for type hints everywhere. It passes mypy in python 3.8
* Remove targets py27, py34, py35, and pypy from `tox.ini`
* Update `README.rst` and remove anything related to Python2
  Mention maintenance branch `maint/v2`
* `setup.py`
  - Update Trove classifiers
  - Require now Python >=3.6.*
  - Remove Tox and Clean classes, try to make it
    as simple as possible
  - Extract metadata directly from source (affects all the __version__,
    __author__ etc. variables)
* `setup.cfg`
  - Add pycodestyle section
* `semver.py`
  - Change version number to "3.0.0-alpha0"
  - Remove old code related to Python2
  - Adjust Python2 vs. Python3 str/bytes
  - Add wheel as another test requirement
* `tox.ini`
  - Remove py27, py34, and py35 (out of maintenance)
  - Add docs to default testenv
  - Remove --universal from bdist_wheel
* Split test suite into separate files under tests/ dir
* Travis: Remove old versions, integrate new
  - Remove 2.7, 3.4, 3.5, and pypy
  - Integrate 3.8, 3.9-dev and nightly builds
  - Allow nightly to fail
* Add .editorconfig to have a consistent editor setup

Co-authored-by: Thomas Laferriere <t.laferriere@hotmail.ca>
* Remove Python2
* Use Roboto font family
  Sans: Roboto (for text)
  "Serif": Roboto Slab (for headings)
  Monospace: Roboto Mono (for code)
* Improve CSS navigation
* Create new logo and move it to docs/_static
* Add new section about how to get the version of semver
* Use a more general term (2.x.y) instead of specific versions
* Number sections
* Rework deps for doc build
* Rework release procedure
* Add `changelog.d/.gitignore` to keep this directory
* Create `changelog.d/README.rst` with some descriptions
* Add `changelog.d/_template.rst` as Towncrier template
* Add `[tool.towncrier]` section in pyproject.toml
* Add "changelog" target into `tox.ini`. Use it like "tox -e changes -- CMD"
  whereas CMD is a towncrier command. The default "tox -e changes"
  calls towncrier to create a draft of the changelog file and
  output it to stdout.
* Update documentation and add include a new section "Changelog"
  included from `changelog.d/README.rst`
* Update changelog.d directory and add new files
@tlaferriere tlaferriere force-pushed the 213-type-hint-from-prep-py3 branch from 9808da4 to 0406432 Compare October 23, 2020 03:30
@tlaferriere
Copy link
Author

I squashed all the commits that made the type hints work so it is clearer.

Copy link
Owner

@tomschr tomschr left a comment

Choose a reason for hiding this comment

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

Thanks @tlaferriere for all your efforts! I left some comments to be discussed.

Apart from that, I've cloned your fork and tried to build it, but it failed. 😢 Haven't found the culprit yet. The result was: 73 failed, 227 passed. Can you confirm? I've used the command tox -e py36 using Python 3.6.

You probably know that already, but I can highly recommend the pyenv project. This allows you to install different Python versions locally in your home without compromising the system installation. That makes it easier to test against different Python versions.

@tomschr tomschr force-pushed the feature/3.0.0-alpha0 branch 2 times, most recently from 32b0c3d to 8d61c9a Compare October 23, 2020 21:55
@tomschr
Copy link
Owner

tomschr commented Oct 23, 2020

Thanks @tlaferriere for all your efforts with type hinting. Very much appreciated! 👍 ❤️

I've reorganized the commits a bit, squashed here and there. Your work is integrated into the commit messages, see PR python-semver#290. Furthermore, I've also added you as co-author.

I additionally changed one thing: I've improved the API documentation. As we have type annotations now, I removed the manual types (:type:, rtype:) inside docstrings. They are not needed anymore. With the help of the sphinx-autodoc-typehints plugin (included), the data types for the input and return types are created automatically.

This makes the docstring more concise and improves readability.

So with all the changes integrated in the above PR, I can close this PR. If you still find any issue, you are more than welcome to open a new one.

Again, thanks for all your contributions!

@tomschr tomschr closed this Oct 23, 2020
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

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy