Skip to content

Conversation

RonnyPfannschmidt
Copy link
Contributor

@RonnyPfannschmidt RonnyPfannschmidt commented Nov 28, 2019

#374 indicates a need for a followup with unifying configuration initialization at the right place,

  • pass configuration data from yaml correctly
  • unify configuration initialization at the configuration class
  • use configuration directly in the integrations

followup in #393

  • harden configuration loading/setup for forward/backward compatibility wrt new arguments
  • sort out if/when to unify configuration argument order (by going kw-only)
  • ensure toml is a hard test dependency

@RonnyPfannschmidt RonnyPfannschmidt changed the title [wip] fix #374 - initialize configuration for toml integration fix #374 - initialize configuration for toml integration Nov 28, 2019
Copy link
Member

@jaraco jaraco left a comment

Choose a reason for hiding this comment

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

Looks great. These changes are definitely preferable to the status quo. I've made a few suggestions; take them or leave them.

defn = __import__("toml").load(strm)
return cls()._load(defn.get("tool", {})["setuptools_scm"])
section = defn.get("tool", {})["setuptools_scm"]
return cls(**section)
Copy link
Member

Choose a reason for hiding this comment

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

The danger (and benefit) to this approach is it couples the class interface to the configuration schema. It's now invalid to have any values in the configuration that aren't supported by the class, which means now users must be much more sensitive to the version of setuptools_scm used, making it more difficult to be forward-compatible (supplying a value that is used if supported but ignored otherwise). It was my intention to be suitably lenient, acknowledging the risk that a user might supply the wrong key (with a typo or something) and that typo would fail silently.

If you want to go with this approach, I'd recommend allowing **kwargs to Configuration() and (if desired) warn if unexpected keyword arguments are found.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, i#ll think about how to layer it in correctly

root=".",
version_scheme="guess-next-dev",
local_scheme="node-and-date",
version_scheme=DEFAULT_VERSION_SCHEME,
Copy link
Member

Choose a reason for hiding this comment

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

These defaults feel duplicative to me. How about instead:

def get_version(*args, **kwargs):
    return _get_version(Configuration(*args, **kwargs))

or get_version = compose(_get_version, Configuration) (where compose is something like this)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

unfortunately the argument order is different compared to Configuration
(this is a general oversight)

i do wonder if perhaps a breaking release should be done about this and the arguments (with some more change accumulated on top)

Copy link
Member

Choose a reason for hiding this comment

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

Is the constructor for Configuration part of a public interface? I'd have imagined that was private, so could adapt to match get_version (maybe; I haven't tried) without affecting compatibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In setuptools_scm I have made some mistakes about the semantics of public vs private, it may be necessary to take time for a detailed workout on that

Copy link
Member

Choose a reason for hiding this comment

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

No problem. Happy to proceed with it as is.



def test_pyproject_support(tmpdir, monkeypatch):
pytest.importorskip("toml")
Copy link
Member

Choose a reason for hiding this comment

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

hmm. I'd prefer to make toml a hard requirement (for tests). Are there circumstances where toml couldn't be required for tests? I'd like to imagine setuptools_scm moving to hard-requiring toml sooner than later.

@layday layday mentioned this pull request Jan 18, 2020
@RonnyPfannschmidt RonnyPfannschmidt mentioned this pull request Jan 18, 2020
3 tasks
@RonnyPfannschmidt RonnyPfannschmidt merged commit eac15d6 into master Jan 18, 2020
@RonnyPfannschmidt RonnyPfannschmidt deleted the fix-374 branch May 2, 2020 07:45
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