-
Notifications
You must be signed in to change notification settings - Fork 96
Create semver package #304
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
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 Thomas for all your good work! Very much appreciated! 👍 ❤️
If we want to create a semver package, it is probably better to use a src-layout. Although there is some disagreement about that, I've read Ionel's and Hynek's blog posts and think it has some value.
That said, I would suggest to use this structure in our root folder:
src/
└── semver
├── cli.py
├── deprecated.py
├── __init__.py
├── __main__.py
├── _types.py
└── version.py
Apart from that, I've commented on some parts. These are some ideas and I'd like to hear your opinion. 🙂
Another question: Did you pull from the upstream project? It looks like there are some old commits there. Not exactly sure how you set up your branch. I would recommend to try to be in sync with the upstream master branch first, otherwise it make things much harder later.
Thanks again!
@tomschr Should I include the tests in the |
No, tests shouldn't be part of the semver package IMHO. Ionel says in his Packaging a Python library article about the tests directory:
Hynek thinks that too and probably a few other. So these are all valid arguments for me to follow this approach. 😉 |
So you still see it even though I resolved the conversation @tomschr |
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.
@tlaferriere This looks really good! 👍 Thanks Thomas for your hard work.
I have a couple of minor comments and questions. All can you find below. Apart from that, I have two things that I would like to discuss:
- The documentation doesn't build yet. Addtionally, for some (unknown) reason, the API section is empty. 🤷♂️ To make the docs build again, we only need a small change here:
diff --git i/docs/conf.py w/docs/conf.py
index 3653ecc..71738da 100644
--- i/docs/conf.py
+++ w/docs/conf.py
@@ -19,7 +19,7 @@
import os
import sys
-sys.path.insert(0, os.path.abspath(".."))
+sys.path.insert(0, os.path.abspath("../src/"))
- The coverage degraded a bit from last release. We should add a short integration test for
semver/__main__.py
. It doesn't need to be necessarily in this PR.
---------- coverage: platform linux, python 3.6.10-final-0 -----------
Name Stmts Miss Branch BrPart Cover Missing
-----------------------------------------------------------------------------------------------------------
.tox/py36/lib/python3.6/site-packages/semver/__about__.py 7 0 0 0 100.0%
.tox/py36/lib/python3.6/site-packages/semver/__init__.py 3 0 0 0 100.0%
.tox/py36/lib/python3.6/site-packages/semver/__main__.py 9 9 2 0 0.0% 7-19
.tox/py36/lib/python3.6/site-packages/semver/_deprecated.py 80 2 14 1 94.7% 182->184, 184-185
.tox/py36/lib/python3.6/site-packages/semver/_types.py 7 0 0 0 100.0%
.tox/py36/lib/python3.6/site-packages/semver/cli.py 60 0 10 0 100.0%
.tox/py36/lib/python3.6/site-packages/semver/version.py 230 1 70 1 99.3% 383->384, 384
-----------------------------------------------------------------------------------------------------------
TOTAL 396 12 96 2 96.3%
Again, I like all the changes! Well done!
If you solved the issues above, it would be great if you could clean up your commits. 👍 🙂 |
bb20850
to
932c190
Compare
Split up changelog to make more sense. Incorporate suggestions and increase coverage to 100% in non-deprecated parts. Bump the dev part Co-authored-by: Tom Schraitle <tomschr@users.noreply.github.com> Run docformatter Fix path for docformatter Add stubby setup.py file for compatibility with python 3.6 Run black Deprecate cli functions imported from root Revert to `pysemver` as console script. Refactor __main__.py * add type hints for correctness * run black Refactor and integrate suggestion from @tomschr * Create :file:`src/semver/cli.py` for all CLI methods * Create :file:`src/semver/_deprecated.py` for the ``deprecated`` decorator and other deprecated functions * Create :file:`src/semver/__main__.py` to allow calling the CLI using :command:`python -m semver` * Create :file:`src/semver/_types.py` to hold type aliases * Create :file:`src/semver/version.py` to hold the :class:`VersionInfo` class and its utility functions * Create :file:`src/semver/__about__.py` for all the metadata variables Adapted infrastructure code to the new project layout. * Replace :file:`setup.py` with :file:`setup.cfg` because the :file:`setup.cfg` is easier to use * Adapt documentation code snippets where needed * Adapt tests * Changed the ``deprecated`` to hardcode the ``semver`` package name in the warning. Change path for docformatter and run it. Remove pyi inclusion from black sine we aren't using them Clean up after messy rebase Run black
932c190
to
79e0c10
Compare
Add documentation for Version rename
79e0c10
to
d38813d
Compare
Create a separate file to describe how to migrate to new semver3.
With ideas from https://stackoverflow.com/a/62613202 * Use autosummary Sphinx extension * Extend docs/config.py * Ignore docs/_autosummary * Add module docstring * Add changelog entry * Improve custom.css for sidebar
Split changelog entries into semver 3 (new) and semver 2 (old).
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 for the coverage and the other improvements! 👍 I have only some minor comments.
Currently, I'm working on improving the API documentation. Expect some commits. I think, I'm almost finished.
:rtype: tuple(:class:`VersionInfo` | None, str) | ||
:rtype: tuple(:class:`Version` | None, str) |
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.
I would completely remove this line as this is created automatically.
@@ -0,0 +1 @@ | ||
Deprecate CLI functions not imported from ``semver.cli``. |
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.
Shouldn't we add another file 305.deprecation.rst
to describe the deprecation of VersionInfo > Version?
Oh, I see, you have that as a documentation issue. Hmn... not sure, if people will find it. IMHO it wouldn't hurt to add this here too.
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.
I think I will just rename the file 305.doc.rst
to 305.deprecation.rst
.
@tlaferriere I researched a bit and found (hopefully) a good solution. Due to changing semver from a package to a module there were some additional changes necessary. The output looks a bit different now, but I think it's okay. Let me know if you think this should be changed. There are some warning messages that are a bit disturbing:
Maybe we need to introduce an Additionally, I've split the changelog into entries for semver3 and semver2. I think, this makes it easier. Hope these changes make sense to you. 😄 |
Co-authored-by: Tom Schraitle <tomschr@users.noreply.github.com>
Co-authored-by: Tom Schraitle <tomschr@users.noreply.github.com>
Acoording to the mentioned PEP: "Package maintainers who wish to support type checking of their code MUST add a marker file named py.typed to their package supporting typing." Add package_data to setup.cfg to include this marker in dist and whl file.
Add missing module docstrings and correct function docstring to avoid warnings (just missing empty lines)
* Use sphinx-apidoc to build API documentation * Amend tox.ini and call sphinx-apidoc * Remove old autosummary; it turned out it was difficult to configure and returned warning messages which were hard to fix.
@tlaferriere I've tried a different approach now. I removed all the
As you can see, there are also some private modules (as
So I'm a bit unsure which would be better. I would have liked to have the content from The above commits contains some improvements of docstrings in modules and functions. Hope I didn't commit anything useless by accident. If you agree with my suggestions, we could arrange and squash the commits and I can merge it to master. |
Since some of the important metadata is imported in the |
Unfortunately not. If I remove the
which is of course nonsense as it kind of copies the docstring from the What I can do is to manually add that. Maybe with
Haha, me too. I hope this makes sense. 😉 |
Can't we just create a template that interpolates these variables? It's not like we're going to change the meaning or the usage of these variables very often 😉. They are accessible from the |
Well, my knowledge about Sphinx and autodoc is limited. I've tried several things, but either I got some warning messages (like the one above) or I didn't get what I wanted. 😉 The autodoc extension can be configured by a autodoc_default_options variable. However, that is limited.
True. But it would be nice to have at least |
* Unorthodox solution with sed * Remove obsolete config variables in docs/config.py * Add docs/_api/semver.__about__.rst as a placeholder
I think I found a (somewhat) unorthodox solution. 😆 The API doc shows now only the public interface, but additionally the If you are okay with that, I would tomorrow squash all the commits into some useful history and merge it to master. Any objections? |
An unorthodox solution is still a solution 😉. If it's that bad I guess we can open an issue with Sphinx for this use case. For now I think this should do. It appears we've got good timing for the second |
Hehe, yes.If it turns out that it is bad, we can always publish a new dev release. I'll go through the commits and try to come up with some decent history. As I heard no "stop" or other objections, I'll merge them to master. 😉 Thanks for all your contributions and efforts! 👍 |
I just realized that it is not possible to rearrange the commits and force-push them into this pull request. I'll open a new branch and merge the commits from there. |
Closing this in favor of #306. |
This closes #169. I am unsure of what to do with the doctests entrypoint, so I put it in its own file.