Skip to content

Magic fixes#138

Merged
tvst merged 7 commits intostreamlit:developfrom
tconkling:tim/MagicBlockStatements
Sep 20, 2019
Merged

Magic fixes#138
tvst merged 7 commits intostreamlit:developfrom
tconkling:tim/MagicBlockStatements

Conversation

@tconkling
Copy link
Copy Markdown
Contributor

@tconkling tconkling commented Sep 18, 2019

  • Magic supports while, async with, async for statements, and async functions
  • Ignore yield and yield from statements (these were previously being magicked, which resulted in random-seeming "None" values being st.written to the report).
  • I also created an examples/magic.py file for easy visual testing of these things, which I used while debugging. (The magic unit tests also verify these fixes.)

Fixes #135

@tconkling tconkling requested review from monchier and tvst September 18, 2019 20:37
@@ -0,0 +1,128 @@
import asyncio
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.

I've been trying to empty our examples/ folder, so I'd like to understand: what is the purpose of this file?

Should this be an e2e test instead? Should we delete it? Or something else?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It can either go away or be an e2e test. I was using it to visually verify that magic was functioning properly. It seemed potentially useful for anyone down the line who was further debugging magic related stuff - but I'm happy to remove it as well.

What's your pref?

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 like a good candidate for a Cypress test

@@ -0,0 +1,128 @@
import asyncio
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 like a good candidate for a Cypress test

self._testCode(CODE_WITH_STATEMENT, 1)

def test_while_statement(self):
"""Test that 'yield' expressions do not get magicked"""
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.

Think you copy pasted the method description but didn't update it.

@tvst
Copy link
Copy Markdown
Contributor

tvst commented Sep 20, 2019

I'm going to merge this so we can have it in today's release, but @tconkling please implement the tests described here next week.

@tvst tvst merged commit f39a6a7 into streamlit:develop Sep 20, 2019
@tconkling tconkling deleted the tim/MagicBlockStatements branch September 23, 2019 16:11
@tconkling tconkling restored the tim/MagicBlockStatements branch September 23, 2019 16:54
@tconkling tconkling mentioned this pull request Sep 23, 2019
@tconkling tconkling deleted the tim/MagicBlockStatements branch September 23, 2019 17:04
tconkling added a commit to tconkling/streamlit that referenced this pull request Sep 23, 2019
* develop:
  Release 0.46.0 (streamlit#170)
  Magic fixes (streamlit#138)
  [docs] Add analytics; redirect /secret/docs; fix compilation problem (streamlit#149)
  Fix bug for startup under windows (streamlit#144)
  Responsive layout (streamlit#104)
  Add basic PR template
  Better method signatures (streamlit#88)
  Publish docs to both /docs and /secret/docs, until we deprecate /secret/docs in January. (streamlit#141)
  Rename/report2app (streamlit#126)
tconkling added a commit to tconkling/streamlit that referenced this pull request Sep 23, 2019
* develop: (54 commits)
  Removing uber demo from streamlit repo (streamlit#159)
  Release 0.46.0 (streamlit#170)
  Magic fixes (streamlit#138)
  [docs] Add analytics; redirect /secret/docs; fix compilation problem (streamlit#149)
  Fix bug for startup under windows (streamlit#144)
  Responsive layout (streamlit#104)
  Add basic PR template
  Better method signatures (streamlit#88)
  Publish docs to both /docs and /secret/docs, until we deprecate /secret/docs in January. (streamlit#141)
  Rename/report2app (streamlit#126)
  Test running streamlit commands "bare" (streamlit#133)
  Updates to LP and sidebar. (streamlit#134)
  tests for z-index of date input popover in sidebar (streamlit#131)
  cypress test for escaping html in markdown (streamlit#125)
  On a Mac, check if xcode installed before requiring watchdog (streamlit#91)
  [Docs] Fix st.slider API in tutorial (streamlit#98)
  Sidebar exceptions (streamlit#107)
  Fixing unbound local variable (streamlit#110)
  Support hashing dataframes with unhashable objects. Gracefully f… (streamlit#118)
  Fix hashing if the object has a name but the name is not a string. (streamlit#117)
  ...
tconkling added a commit that referenced this pull request Sep 24, 2019
Re-implements the `examples/magic.py` from #138 as an e2e test.
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.

Make sure magic works with all block statements in Python

3 participants