Minor nitpick in the Fuzzer class defenition#106
Closed
hexagonrecursion wants to merge 1 commit intouds-se:masterfrom
Closed
Minor nitpick in the Fuzzer class defenition#106hexagonrecursion wants to merge 1 commit intouds-se:masterfrom
hexagonrecursion wants to merge 1 commit intouds-se:masterfrom
Conversation
The current code says: ```py # Note: the list comprehension below does not invoke self.run() for subclasses # return [self.run(runner) for i in range(trials)] ``` The code uses this as a justification to use a loop instead of a list comprehension. This is incorrect: self.run() inside a list comprehension calls the correct subclass method just fine. Proof: https://mybinder.org/v2/gh/hexagonrecursion/fuzzingbook.git/proof?filepath=docs%2Fnotebooks%2FFuzzer-proof.ipynb ```py class Fuzzer(object): def __init__(self): pass def fuzz(self): """Return fuzz input""" return "" def run(self, runner=Runner()): """Run `runner` with fuzz input""" return runner.run(self.fuzz()) def runs(self, runner=PrintRunner(), trials=10): """Run `runner` with fuzz input, `trials` times""" return [self.run(runner) for i in range(trials)] class Foo(Fuzzer): def run(self, runner=Runner()): print('Foo.run') Foo().runs() ``` ``` Foo.run Foo.run Foo.run Foo.run Foo.run Foo.run Foo.run Foo.run Foo.run Foo.run [None, None, None, None, None, None, None, None, None, None] ```
Member
|
Hi @hexagonrecursion, can you explain the actual change? Is this simply to remove the note? The github diff doesn't know about Jupyter notebooks, and the diff it shows is incomprehensible. |
andreas-zeller
added a commit
that referenced
this pull request
Feb 21, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current code says:
The code uses this as a justification to use a loop instead of a list comprehension. This is incorrect: self.run() inside a list comprehension calls the correct subclass method just fine. Proof: https://mybinder.org/v2/gh/hexagonrecursion/fuzzingbook.git/proof?filepath=docs%2Fnotebooks%2FFuzzer-proof.ipynb