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

Email example using imaginary library installation error. #82530

Closed
jackotonye mannequin opened this issue Oct 2, 2019 · 11 comments
Closed

Email example using imaginary library installation error. #82530

jackotonye mannequin opened this issue Oct 2, 2019 · 11 comments
Labels
3.12 docs Documentation in the Doc dir expert-email

Comments

@jackotonye
Copy link
Mannequin

jackotonye mannequin commented Oct 2, 2019

BPO 38349
Nosy @warsaw, @terryjreedy, @bitdancer, @maxking

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2019-10-02.16:10:03.652>
labels = ['3.8', 'docs', '3.7', '3.9', 'performance']
title = 'Email example using imaginary library installation error.'
updated_at = <Date 2019-10-05.16:15:18.636>
user = 'https://bugs.python.org/jackotonye'

bugs.python.org fields:

activity = <Date 2019-10-05.16:15:18.636>
actor = 'maxking'
assignee = 'docs@python'
closed = False
closed_date = None
closer = None
components = ['Documentation']
creation = <Date 2019-10-02.16:10:03.652>
creator = 'jackotonye'
dependencies = []
files = []
hgrepos = []
issue_num = 38349
keywords = []
message_count = 9.0
messages = ['353743', '353745', '353755', '353997', '353998', '354015', '354016', '354017', '354018']
nosy_count = 7.0
nosy_names = ['barry', 'terry.reedy', 'r.david.murray', 'SilentGhost', 'docs@python', 'maxking', 'jackotonye']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'resource usage'
url = 'https://bugs.python.org/issue38349'
versions = ['Python 3.7', 'Python 3.8', 'Python 3.9']

@jackotonye
Copy link
Mannequin Author

jackotonye mannequin commented Oct 2, 2019

@jackotonye jackotonye mannequin assigned docspython Oct 2, 2019
@jackotonye jackotonye mannequin added docs Documentation in the Doc dir performance Performance or resource usage labels Oct 2, 2019
@jackotonye jackotonye mannequin changed the title Email example using imaginary library installation error. The install shows that it only supports python 2.x but is listed for python 3.6+ Email example using imaginary library installation error. The install shows that it only supports python 2.x but is listed under python 3.6+ docs. Oct 2, 2019
@SilentGhost
Copy link
Mannequin

SilentGhost mannequin commented Oct 2, 2019

imaginary in the example is not meant to refer to https://pypi.org/project/Imaginary/ it's meant to refer to a module that you could write that would do all the dirty work. Perhaps, it's not the best name to use provided there is an actual module on pypi, alternatively half-baked outdated modules could be remove.

@jackotonye
Copy link
Mannequin Author

jackotonye mannequin commented Oct 2, 2019

Might be best to make it a little more obvious since most examples are
considered executable code. That would require little modification.

On Wed, Oct 2, 2019 at 12:20 PM SilentGhost <report@bugs.python.org> wrote:

SilentGhost <ghost.adh@runbox.com> added the comment:

imaginary in the example is not meant to refer to
https://pypi.org/project/Imaginary/ it's meant to refer to a module that
you could write that would do all the dirty work. Perhaps, it's not the
best name to use provided there is an actual module on pypi, alternatively
half-baked outdated modules could be remove.

----------
nosy: +SilentGhost


Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38349\>


@terryjreedy
Copy link
Member

terryjreedy commented Oct 5, 2019

The rest of the overly long title was "The install shows that it only supports python 2.x but is listed under python 3.6+ docs."

The lines in question are from the 2nd to last example.

  # An imaginary module that would make this work and be safe.
  from imaginary import magic_html_parser

The comment plus the names 'imaginary' and 'magic_html_parser' should make it pretty clear that 'imaginary' is meant to be an imaginary, hypothetical module with an imaginary, hypothetical method, not an actual module named 'imaginary' with an actual 'magic_html_parser' method.

jackotonye, do you have a concrete suggestion? I am tempted to close this, but will wait for suggestion and let the email people see this.

Also, when responding by email, please remove the quoted previous post and it is redundant on the web page.

@terryjreedy terryjreedy changed the title Email example using imaginary library installation error. The install shows that it only supports python 2.x but is listed under python 3.6+ docs. Email example using imaginary library installation error. Oct 5, 2019
@SilentGhost
Copy link
Mannequin

SilentGhost mannequin commented Oct 5, 2019

One fairly naive solution would be to define a magic_html_parser directly in the example and move explanatory comment there. In order not to break the code it could return an empty string.

@maxking
Copy link
Contributor

maxking commented Oct 5, 2019

The function of this imaginary method is described below:

# The magic_html_parser has to rewrite the href="cid:...." attributes to
# point to the filenames in partfiles.  It also has to do a safety-sanitize
# of the html.  It could be written using html.parser.

This implementation is going to be non-trivial (more than just a wrapper around html.parser) I think, and I would like to not make the example related to email even longer due to that implementation.

And I agree with Terry, the comment should make it pretty clear, there aren't any dependencies in the examples outside of standard library.

Any other synonym that we'd choose could end up being a package in pypi someday :)

@maxking
Copy link
Contributor

maxking commented Oct 5, 2019

The comment should make it clear that it is an made up imaginary module. The no dependencies outside of standard library is not written, I guess?

@jackotonye
Copy link
Mannequin Author

jackotonye mannequin commented Oct 5, 2019

I’m fine with closing the issue.

Seems trivial now after reading the comments but noting that most developers take examples as running code and spend less time going over the comments and a dependency that had similar names makes it even harder to make the point.

If the comment was at the usage rather than at import it would be more obvious that it needs to be a custom implementation.

@maxking
Copy link
Contributor

maxking commented Oct 5, 2019

We could move that comment to the top near the import, I am totally fine with that.

@iritkatriel
Copy link
Member

iritkatriel commented Aug 17, 2022

We could also rename imaginary to imaginary_module and then it won't look like a real module name.

@iritkatriel iritkatriel removed the performance Performance or resource usage label Aug 17, 2022
@terryjreedy
Copy link
Member

terryjreedy commented Sep 20, 2022

The file under consideration was written by R. David Murray in 2014, with little revision since. The suggestions include: do nothing; rewrite the import comment; change the fake name (in particular, to imaginary_module); move the function description up to the import; and turn the function description into a docstring for a def that replaces the import (SilentGhost). There was no consensus on which to do.

Stanley(slateny)'s PR changes the import name and moves the fake function description up. After reading it and thinking more, I prefer SilentGhost's idea, except that I would want to raise rather than return an empty string. One reason is that understanding the function description requires knowing its signature. I presume that this is why David put the comment where he did, just above the call that shows the intended signature.

So, replace the import and its comment and turn the current multiline function comment into a docstring as follows.

def magic_html_parser(html_text, partfiles):
    """Return safety sanitized html linked to partfiles.

   Rewrite the href="cid:...." attributes to point to the filenames in partfiles.
   Though not trivial, this should be possible using html.parser.
    """
    raise NotImplementedError("Add the magic needed")

I am giving slateny at least a week to write a new PR if he wishes.

terryjreedy added a commit that referenced this issue Sep 26, 2022
…xample (#97529)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 26, 2022
…mail example (pythonGH-97529)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
(cherry picked from commit 2b428a1)

Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 26, 2022
…mail example (pythonGH-97529)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
(cherry picked from commit 2b428a1)

Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
miss-islington added a commit that referenced this issue Sep 26, 2022
…xample (GH-97529)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
(cherry picked from commit 2b428a1)

Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
miss-islington added a commit that referenced this issue Sep 26, 2022
…xample (GH-97529)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
(cherry picked from commit 2b428a1)

Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
pablogsal pushed a commit that referenced this issue Oct 22, 2022
…xample (GH-97529)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
(cherry picked from commit 2b428a1)

Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 docs Documentation in the Doc dir expert-email
Projects
None yet
Development

No branches or pull requests

4 participants