Skip to content

Make --strict imply --strict-config / xfail_strict? #7503

Closed

Description

@The-Compiler

With pytest 4.5.0 (May 2019), we introduced --strict-markers as a replacement for --strict, and said:

The existing --strict option has the same behavior currently, but can be augmented in the future for additional checks.

With #7286, now we also have --strict-config. Yet, --strict is still an alias for --strict-markers.

Given that pytest 6 is allowed to do breaking changes, wouldn't it make sense for --strict to imply both --strict-markers and --strict-config now?

(Though, on a second thought: Do we actually need --strict-markers in pytest 6 still, given the warning system? Probably still useful as a convenient way to turn those warnings into errors?)

This would also make pytest more in line with other tools with a --strict flag - mypy and tsc (the typescript compiler) come to mind, where --strict implies various different strict flags.

cc @gnikonorov (who added --strict-config), @webknjaz and @DahlitzFlorian (some existing discussion in #7233), and @nicoddemus (#5023) - what do you think?

Activity

  1. webknjaz commented on Jul 15, 2020

    @webknjaz
    Member

    I think it's a good idea to have some --strict-all-the-things that would imply enabling all strictness-related settings. What I'm not sure about is how it should be called. I'm okay with just --strict but Bruno mentioned earlier that it used to mean just "strict-markers" for a while so such semantics change may be confusing. OTOH personally I can live with that and I'm not really concerned about this name. I think it should be decided by the folks who feel differently.

  2. webknjaz commented on Jul 15, 2020

    @webknjaz
    Member

    The only thing I want to add is that I'd probably expect it to also be a config value rather than just a CLI option.

  3. added
    type: proposalproposal for a new feature, often to gather opinions or design the API around the new feature
    on Jul 15, 2020
  4. Zac-HD commented on Jul 15, 2020

    @Zac-HD
    Member

    I like the idea of --strict or strict = True implying all the strictness options.

    Whether we still need it with the warnings system or not, I think we should keep it until pytest 7 rather than scrambling to make such a large change now.

  5. DahlitzFlorian commented on Jul 15, 2020

    @DahlitzFlorian
    Member

    I really like the idea of using --strict to activate all --strict* options. However, I would suggest adding a note to the documentation that --strict will have that behavior in version x.x and people should be aware of it. Of course, we already added a note that it might happen, but an explicit note that it is going to happen in version x.x is highly preferred.

    IMHO we can discuss whether we need to wait until version 7 or can include it in some minor version of pytest 6.

  6. symonk commented on Jul 15, 2020

    @symonk
    Member

    Should we consider giving the user the option?

    --strict=all | --strict=marker | --strict=config

    Im just wondering if we add future 'strictness' but have then coupled the user into all or none situations.

  7. The-Compiler commented on Jul 15, 2020

    @The-Compiler
    MemberAuthor

    @symonk We already have --strict-markers and --strict-config, I don't think we should have a second way to do the same thing.

  8. DahlitzFlorian commented on Jul 15, 2020

    @DahlitzFlorian
    Member

    Totally agree with @The-Compiler. In fact, --strict should be a shortcut for using all --strict* options.

  9. gnikonorov commented on Jul 15, 2020

    @gnikonorov
    Member

    No objections from me at all. --strict should imply all strict flags IMO, as @DahlitzFlorian mentions above.

  10. added this to the 6.0 milestone on Jul 22, 2020
  11. The-Compiler commented on Jul 22, 2020

    @The-Compiler
    MemberAuthor

    I opened a PR: #7529

  12. graingert commented on Jul 22, 2020

    @graingert
    Member

    Given that pytest 6 is allowed to do breaking changes

    Can we flip the default here so markers default to strict in v6?

    What about xfail_strict

  13. The-Compiler commented on Jul 22, 2020

    @The-Compiler
    MemberAuthor

    Can we flip the default here so markers default to strict in v6?

    We already have a warning for that since 4.5.0, so it should be quite clear what's going on even without --strict-markers. -1 on making that the default now, that seems a bit late.

    What about xfail_strict

    That one is much more controversial and I'm not sure if starting the discussion again will produce a different outcome. See #1299 and #814.

  14. graingert commented on Jul 22, 2020

    @graingert
    Member

    We could then change the default to True in a future release so pytest by default will be more strict

    From @nicoddemus seems like this is exactly that future release

  15. graingert commented on Jul 22, 2020

    @graingert
    Member

    I think if we add strict-markers and strict-config to --strict we should also have it cover xfail_strict

  16. 14 remaining items

  17. nicoddemus commented on Jul 23, 2020

    @nicoddemus
    Member

    Good point, but I think we should rather close #7233 and keep this one open, as I believe this discussion is more through and brought more ideas on how to move things forward. 👍

  18. changed the title [-]pytest 6: Make --strict imply --strict-config?[/-] [+]Make --strict imply --strict-config / xfail_strict?[/+] on Jul 23, 2020
  19. graingert commented on Jul 5, 2021

    @graingert
    Member

    what about passing a pypi major version to strict: --strict=7 any new strictness settings will be graded with the major version they are added in, then --strict will enable any flags that are greater than that version.

    Then people can pass --strict=inf to opt into all strictness settings

  20. graingert commented on Jul 5, 2021

    @graingert
    Member

    then you can keep --strict with no = deprecated forever

  21. The-Compiler commented on Jul 5, 2021

    @The-Compiler
    MemberAuthor

    I'm not sure what problem that would solve. Major releases come with some breakage, so projects likely need to adapt a little anyways - I don't see an issue with making --strict imply ~all strict settings and adding to it, especially in major releases. This just seems like very unusual UX and a solution without a problem IMHO 😉

  22. graingert commented on Jul 5, 2021

    @graingert
    Member

    Usually new strict options get added in minor releases because they're not a breaking change. If we made --strict a recommendation then release managers would have to delay every new flag to a new major release

  23. RonnyPfannschmidt commented on Jul 6, 2021

    @RonnyPfannschmidt
    Member

    Having new strict flags trigger warnings until the next major release seems like a good idea anyway

    Having strict simply error on all from the last major release and warn on the new ones seems like a nice plan to me

  24. The-Compiler commented on Jul 6, 2021

    @The-Compiler
    MemberAuthor

    I don't follow. The whole point of the strict flags (at least the ones we have so far) is to turn warnings into errors?

  25. graingert commented on Jul 6, 2021

    @graingert
    Member

    You're saying Pytest 7 should just enable strict-config and strict-markers by default?

  26. The-Compiler commented on Jul 6, 2021

    @The-Compiler
    MemberAuthor

    I'm not sure where you see me saying that. I'm saying --strict should imply both --strict-config and --strict-markers, with us being free to add more strictness settings over time if needed.

  27. graingert commented on Jul 6, 2021

    @graingert
    Member

    My usecase/workflow is that I want to opt into all breaking warnings and exceptions and strictness settings and then dependabot will make a new PR where I manually disable any errors I can't fix immediately

  28. The-Compiler commented on Jul 6, 2021

    @The-Compiler
    MemberAuthor

    For the unlikely situation that --strict with a new pytest version implies --strict-frobnication and you can't fix that right away, you could always replace --strict by --strict-config --strict-markers temporarily. It's not like we're going to have hundreds of new strict options suddenly. I feel like we're thoroughly overengineering something simple at this point.

  29. modified the milestones: 8.0, 9.0 on Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: proposalproposal for a new feature, often to gather opinions or design the API around the new feature

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions