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

needs_nox in noxfile #210

Conversation

Paulius-Maruska
Copy link
Contributor

Hello, in an attempt to familiarize myself with nox code, I managed to implement #99

@theacodes
Copy link
Collaborator

@crwilcox @dhermes @stsewd do any of you have a moment to look at this? I don't have the bandwidth right now.

@Paulius-Maruska thank you for submitting this!

Copy link
Collaborator

@stsewd stsewd left a comment

Choose a reason for hiding this comment

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

Nice approach!

docs/config.rst Outdated Show resolved Hide resolved
nox/_version.py Outdated Show resolved Hide resolved
nox/_version.py Show resolved Hide resolved
@Paulius-Maruska
Copy link
Contributor Author

I have updated the PR, and also rebased it on the latest master branch.

Copy link
Collaborator

@crwilcox crwilcox left a comment

Choose a reason for hiding this comment

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

Thank you for the PR. I left a couple of comments that I would like follow up on, but overall this looks good.


import nox

needs_nox = '2019.5.30'
Copy link
Collaborator

Choose a reason for hiding this comment

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

echoing a comment from @dhermes on the issue. This noxfile.py would result in pylint throwing lint_test.py:3:0: C0103: Constant name "needs_nox" doesn't conform to UPPER_CASE naming style (invalid-name)

Any objections to changing this to a constant?

# limitations under the License.

# future version, to make sure error is logged and returned
needs_nox = "3001.1.1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems a bit 'heavy' to have multiple resources files to validate this. Could these be generated at test time? How are these unique to the tests in test_version?

assert tasks.load_nox_module(config) == 2


def test_load_nox_module_returns_2_when_noxfile_does_not_even_import():
Copy link
Collaborator

Choose a reason for hiding this comment

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

It isn't clear to me what this validates. Is this validating the ordering of errors? That we will mention that we have an invalid arg to the decorator before the version?

assert needed is None


def test_is_version_sufficient_returns_true_for_lower_version():
Copy link
Collaborator

Choose a reason for hiding this comment

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

should there be a case for exact match?

Minimum required nox version
----------------------------

Minimum required Nox version can be specified in your ``noxfile.py`` file by simply defining
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick: may make sense to drop the word 'simply' as there can be negative feelings about that verbiage in prose.

Suggested change
Minimum required Nox version can be specified in your ``noxfile.py`` file by simply defining
Minimum required Nox version can be specified in your ``noxfile.py`` file by defining

@theacodes
Copy link
Collaborator

In terms of placating linters and continuing to be somewhat idiomatic, what do y'all think of making needs_version a member of the nox module?

import nox

nox.needs_version = ">=2018.7.8"
nox.options.sessions = ["lint", "tests-3.6"]

@nox.session
def lint(s):
    ...

...

@crwilcox
Copy link
Collaborator

crwilcox commented Jul 9, 2019

I think adding this to the module would make sense. It also may be more discoverable via language intelligence services in IDEs. Though my big sticking point is matching PyLint, just to avoid the bug that will follow if this doesn't :D

if needed_version and needed_version > nox_version():
logger.error(
"Noxfile {} needs at least Nox {} and therefore it cannot be used "
"with this version.".format(noxfile, str(needed_version))
Copy link
Collaborator

Choose a reason for hiding this comment

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

This message could include the current nox version too

return needs_version


def needs_nox(noxfile, noxfile_module=None):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Np: this function is doing two things. And only using one arg. If noxfile and noxfile module are given, noxfile module is only used

@Paulius-Maruska
Copy link
Contributor Author

I'm sorry for the silence this past week - I was attending the EuroPython2019 conference and was quite busy with the various activities here. :)

I will try to address the issues / respond next week as early as I can.

@theacodes
Copy link
Collaborator

theacodes commented Jul 15, 2019 via email

@theacodes
Copy link
Collaborator

I'm going to close this PR due to inactivity. That's not to say I'm not interested in merging it! If you're still up for it just reply and I'll re-open the PR. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants