Skip to content
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

Be nicer about possible misconfigurations #1004

Open
wants to merge 109 commits into
base: main
Choose a base branch
from

Conversation

thejcannon
Copy link
Contributor

Fixes #1003 by turning situations where the user might get an AssertionError and turn them into descriptive ValueErrors.

Additionally, tests have been added to test the behavior.

The situations fixed are (with the real-world facepalm situations I ended up in):

  • The entrypoint for version_scheme and local_scheme don't exist
    • 🤦 I accidentally used the function name once, instead of the entrypoint name
  • The entrypoint(s) for version_scheme and local_scheme don't return anything
    • 🤦 I forgot to add a return to my custom scheme
  • The tag_regex is bad, and was loaded from the config
    • 🤦 This one should be self-explanatory
  • The tag_regex matched, but the version was blank
    • 🤦 My regex was borked

con-f-use and others added 8 commits October 20, 2023 16:19
* Add "just-tag"

* docs too

* rename

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Rename

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Dont autoformat this

* docs warning

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Copy link
Contributor

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

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

i like the idea behind how the details change, but i aslo beleive a larger change is necessary to do the path/version scheme handling in a better way

due to personal time constraints it may take a be a while to propperly reiterate this

thank you for getting the ball rolling and preparing this as a initial vesion

warnings.warn(
"Expected tag_regex to contain a single match group or a group named"
" 'version' to identify the version part of any tag."
raise ValueError(
Copy link
Contributor

Choose a reason for hiding this comment

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

this one is possibly a breaking change im not sure we can integrate it off hand

@@ -105,6 +105,9 @@ class Configuration:

parent: _t.PathT | None = None

def __post_init__(self) -> None:
self.tag_regex = _check_tag_regex(self.tag_regex)
Copy link
Contributor

Choose a reason for hiding this comment

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

taking this here without leaving it in place creates potental trouble for valies valid in config but not in the config objects

@@ -139,13 +142,11 @@ def from_data(
given configuration data
create a config instance after validating tag regex/version class
"""
tag_regex = _check_tag_regex(data.pop("tag_regex", None))
Copy link
Contributor

Choose a reason for hiding this comment

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

this check needs to say even if the validation gets more struct

DimitriPapadopoulos and others added 29 commits August 6, 2024 11:34
I found the current discussion around version files somewhat
confusing.

When you're reading the usage guide, the second point is telling you
to make a version file; strongly implying you should.  But in reality,
you most likely do not need to bother with keeping a specific version
file.  Explain more clearly about the implications of this.

Under this is a section on using `python -m setuptools_scm --help`
which seems like an orphan from the "as a cli" section; move it down
there.

The runtime section starts by telling you what is strongly discouraged
without explaination why.  Make it clearer by giving the first example
as the most supported thing, which is using standard importlib; then
briefly discuss the version file from above, explaining what's in it
for a standard Python template, then the strongly discouraged direct
import method.

In the config doc, update to discuss `importlib` for consistency.

Correct some capitalization and other minor formatting bits while
we're here.
Rename the project to setuptools-scm
Better cleanup PYTHONPATH for Mercurial calls (support for PDM)
I had a difficult time finding the implementations in the docs, despite knowing of their existence. Adding this cross-reference should help.

x
In PEP 440, "local" refers to the optional portion of a version after the `+` <https://peps.python.org/pep-0440/#local-version-identifiers>. But `version_scheme` doesn't apply to this part.
Most people reading this sentence probably don't have PEP 440 memorized.
Improve the docs about `version_scheme` and `local_scheme`
Fixes pypa#1090. Pinned requirement to tomli<=2.0.2.
Add a lower bound pin on setuptools dependency
docs: clarify usage of version files
pipx.run entry-points should be setuptools-scm
Mention SETUPTOOLS_SCM_PRETEND_VERSION_FOR in error message
@RonnyPfannschmidt
Copy link
Contributor

i pushed a merge to validate with current code - i have to do a release before merging this

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.

Be a smidge more error tolerant?