Skip to content

A few minor fixes#224

Merged
goodboy merged 4 commits into
pytest-dev:masterfrom
bluetech:fixes1
Jul 24, 2019
Merged

A few minor fixes#224
goodboy merged 4 commits into
pytest-dev:masterfrom
bluetech:fixes1

Conversation

@bluetech

Copy link
Copy Markdown
Member

Please see the commit messages.

bluetech added 2 commits July 21, 2019 22:30
`defaults` is the default values e.g. `1` in `foo=1`. It's just used to
find the offset of the kwargs, but the code reused the name which made
me scratch my head for a minute.
@codecov-io

codecov-io commented Jul 21, 2019

Copy link
Copy Markdown

Codecov Report

Merging #224 into master will decrease coverage by 0.8%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #224      +/-   ##
==========================================
- Coverage   93.88%   93.08%   -0.81%     
==========================================
  Files           9       14       +5     
  Lines        1129     1677     +548     
  Branches       21      117      +96     
==========================================
+ Hits         1060     1561     +501     
- Misses         66      101      +35     
- Partials        3       15      +12
Impacted Files Coverage Δ
testing/test_multicall.py 99.27% <100%> (+0.65%) ⬆️
src/pluggy/hooks.py 94.35% <80%> (ø)
src/pluggy/_tracing.py 100% <0%> (ø)
src/pluggy/__init__.py 75% <0%> (ø)
src/pluggy/manager.py 94.62% <0%> (ø)
src/pluggy/callers.py 79.2% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8aa5592...95dd65f. Read the comment docs.

@goodboy goodboy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Made a few suggestions @bluetech but looks good so far!
Thanks for the effort 👍

Comment thread testing/test_multicall.py
hookimpl = HookimplMarker("example")


def test_uses_copy_of_methods():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@bluetech you're saying this test was broken for you?

I don't recall seeing that issue but we are planning on removing all of this as per #59 anyway.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The test has a typo return instead of assert. If the typo is fixed, it fails. Actually the methods are not copied. Since I think the test is ill conceived and tests deprecated functionality, I opted to just remove it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sounds good.

Comment thread docs/index.rst

# call with history; no results returned
pm.hook.myhook.call_historic(config=config, args=sys.argv, result_callback=callback)
pm.hook.myhook.call_historic(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice catch!

Comment thread src/pluggy/manager.py Outdated
res = getattr(method, self.project_name + "_impl", None)
except Exception:
res = {}
normalize_hookimpl_opts(res)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm maybe we could do the same single conditional block like at line 111 at the end of this method?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I can't figure out what "same single conditional block like at line 111" refers to, can you explain more?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ahh sorry my local version of the code is out of date. So basically a block like this at the end of this method which does the normalization if res != None. This might also mean we can remove line 116? A brief look shows this is the only place that method is used internally so I think we might be ok with that change.

@RonnyPfannschmidt @nicoddemus do we use that function in pytest for some reason?

@goodboy goodboy Jul 22, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Doesn't look like it. @bluetech I think you should be fine to factor that call into parse_hookimpl_opts() and remove it from 116.

Probably makes sense to have normalization be atomic with the parsing steps but lets see what others think.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There is a test test_parse_hookimpl_override which overrides parse_hookimpl_opts, returns {} and expects it to work. I did not consider this option so the premise of my commit was wrong. I removed it.

Comment thread src/pluggy/hooks.py
if defaults:
index = -len(defaults)
args, defaults = args[:index], tuple(args[index:])
args, kwargs = args[:index], tuple(args[index:])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agreed that this name is better.

bluetech added 2 commits July 23, 2019 00:10
The test passes invalid values to the instance (it does not takes
functions, it takes HookImpls). The test fails, but it accidentally used
`return` instead of `assert` so it wasn't visible.

Since what is being tested is evidently unimportant and legacy, just
remove it.
It doesn't take `**kwargs` but an argument `kwargs`.

@goodboy goodboy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks fine to me. I am still interested if we can factor that normalization step into the parse method. Despite there being a test for overriding it I'm betting no client code is actually doing that. Might be worth creating a new issue to play with?

@asottile asottile left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@goodboy goodboy merged commit a1c6c35 into pytest-dev:master Jul 24, 2019
@bluetech bluetech deleted the fixes1 branch June 28, 2020 08:40
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.

4 participants