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

Make pragma syntax more intutive #188

Open
edmorley opened this issue Dec 22, 2022 · 3 comments
Open

Make pragma syntax more intutive #188

edmorley opened this issue Dec 22, 2022 · 3 comments

Comments

@edmorley
Copy link

edmorley commented Dec 22, 2022

In #179 and #187, there was confusion about the current pragma syntax, and that pragma: some actually means pragma: no cover if some.

Whilst the situation can be improved by README changes (covered by #187), I wonder whether adjusting the supported syntax might help make the rules self-documenting, and reduce the chance for confusion?

For example, what about this syntax?

# pragma: no cover py-gte-311

ie: coverage-conditional-plugin would strip the literal string prefix no cover (if found), leaving the rule name of py-gte-311, and then behave as it does currently.

This syntax has the advantage of being clearer, and also has a nice parity with the existing no cover syntax.

For backwards compatibility (and to support a more concise syntax for people who prefer it), coverage-conditional-plugin could still support the current syntax alongside the above new syntax.

@sobolevn
Copy link
Member

Yes, I agree that this is a good idea. Current syntax is too counter-intuitive.

@yanyongyu
Copy link

yanyongyu commented Mar 29, 2023

Any update on this? I just write the pragma rules which like the example in the readme and find it not working. 😂 Debug and read the source code... i have to invert all the rule now.

@inorton
Copy link

inorton commented May 21, 2023

Without any code changes, the confusion comes because the examples look like they mean "turn on coverage if the rule matches" when it is the opposite.

This would be clearer just having an example like:

rules = 
  "sys.platform == 'linux'": no cover if linux

Would be clearer with a code sample like:

def test_windows_only(): # pragma: no cover if linux
    assert True

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

No branches or pull requests

4 participants