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

Code-level simplifications to tracing #226

Merged
merged 8 commits into from
Aug 30, 2019

Conversation

bluetech
Copy link
Member

A few minor changes relating to the tracing stuff. Please see the commits.

The way _TracedHookExecution is implemented, it takes the PluginManager
instance, which creates a cyclic dependency between the manager.py and
_tracing.py modules. It also mutates internal variables of
PluginManager. This makes the code harder to understand. Just inlining
it makes things mostly straightforward.

This commit also removes an assert which prevented a trace from being
added if there is already an active one. I don't see any reason why it
was done; seems like a legitimate thing to do and should work just fine.
This function is undocumented and unused internally.

pytest used to use it in a test case, but hasn't done so since 2010:
pytest-dev/pytest@b3628da#diff-5fd183e022c6cb9ca47f6c1ffc09eadeL274

A code search on GitHub only finds it inside copies of pluggy itself.
They are only directly used internally and not documented,

Makes it easier to see what is exposed.
It was only used as a kind of namespacing, but it makes things harder to
follow. Since TagTracerSub doesn't have any side-effects, avoid storing
it and make its use entirely localized.

pytest, devpi and tox don't use PluginManager.hook._trace.
If a KeyError is raised by the user-supplied processor function, it
should propagate.
The key is a "path" (tuple) of tags, not a single tag.
@codecov-io
Copy link

codecov-io commented Jul 26, 2019

Codecov Report

Merging #226 into master will increase coverage by 0.78%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #226      +/-   ##
==========================================
+ Coverage   93.08%   93.86%   +0.78%     
==========================================
  Files          14        9       -5     
  Lines        1677     1109     -568     
  Branches      117       19      -98     
==========================================
- Hits         1561     1041     -520     
+ Misses        101       66      -35     
+ Partials       15        2      -13
Impacted Files Coverage Δ
testing/test_tracer.py 100% <100%> (ø) ⬆️
src/pluggy/__init__.py
src/pluggy/callers.py

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 a1c6c35...8900b4c. Read the comment docs.

@bluetech bluetech mentioned this pull request Jul 26, 2019
@bluetech bluetech changed the title Code-level simplicitations to tracing Code-level simplifications to tracing Jul 26, 2019
Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

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

Overall nice changes, sorry about the delay!

src/pluggy/manager.py Show resolved Hide resolved
src/pluggy/_tracing.py Show resolved Hide resolved
src/pluggy/_tracing.py Show resolved Hide resolved
src/pluggy/_tracing.py Show resolved Hide resolved
Copy link
Member Author

@bluetech bluetech left a comment

Choose a reason for hiding this comment

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

Thanks for the review @nicoddemus - left a reply.

src/pluggy/_tracing.py Show resolved Hide resolved
src/pluggy/manager.py Show resolved Hide resolved
@nicoddemus
Copy link
Member

Looks great, thanks again. @goodboy would you like to review as well?

self._tag2proc = {}
self.writer = None
self._tags2proc = {}
self._writer = None
Copy link
Member

Choose a reason for hiding this comment

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

as far as i can tell the "writer" is a "print" style function we ight be able to simplify

Copy link
Member

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

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

looks good, i wonder if setwriter could be deprecated in davour of naming _writertoprinter`

as far as i can tell, all writer is, is a optional printer

overall this is fine to merge as is, good work

@nicoddemus
Copy link
Member

@goodboy, absolutely no rush here, but would you like for us to wait here so you can review this, or are you OK with us merging this? 😁

@goodboy
Copy link
Contributor

goodboy commented Aug 28, 2019

@nicoddemus so sorry!
Been totally immersed in finishing up a music project.
I will take a look tonight!

@nicoddemus
Copy link
Member

No worries at all, take your time. 👍

Copy link
Contributor

@goodboy goodboy left a comment

Choose a reason for hiding this comment

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

@bluetech awesome work!

I made a couple minor notes but this looks great.
Thanks again!

src/pluggy/_tracing.py Outdated Show resolved Hide resolved
src/pluggy/_tracing.py Show resolved Hide resolved
src/pluggy/_tracing.py Show resolved Hide resolved
src/pluggy/manager.py Show resolved Hide resolved
@bluetech
Copy link
Member Author

Updated with @goodboy's suggestion.

@goodboy goodboy merged commit e40a877 into pytest-dev:master Aug 30, 2019
@goodboy
Copy link
Contributor

goodboy commented Aug 30, 2019

@bluetech thanks again for the help!

More eyes on this puppy is great to see!

@bluetech bluetech deleted the simplify-tracing branch June 28, 2020 08:41
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.

5 participants