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

[stdlib] Fix docstring examples in Dict. #3688

Open
wants to merge 1 commit into
base: nightly
Choose a base branch
from

Conversation

helehex
Copy link
Contributor

@helehex helehex commented Oct 17, 2024

Some general questions/notes about the topic of docstring examples:
Do we want the docstring examples to pass tests as a standalone thing,
Or, should we make them smaller and just ensure that they make sense in the context (for example, do we add imports, do we make sure that all variables are initialized, etc..)

Another thing (unrelated to Dict): Some examples don't pass when run with mojo test, but they do work when copied into a main function (namely, io.mojo). I'm treating them as working.

@helehex helehex requested a review from a team as a code owner October 17, 2024 23:57
from collections import Dict

var dict = Dict[String, Int]()
dict["a"] = 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Could you replace dict with d? dict causes incorrect syntax highlighting on GH. Maybe also remove `var.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Highlighting looks fine for me.
Also, I try to avoid single letter names, would using my_dict work?

Copy link
Contributor

@soraros soraros Oct 18, 2024

Choose a reason for hiding this comment

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

Screenshot 2024-10-18 at 19 20 39

dict will be blue because Python. my_dict works.

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.

2 participants