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

f-string: unmatched '(' when importing yfinance #2093

Open
FX196 opened this issue Oct 21, 2024 · 10 comments
Open

f-string: unmatched '(' when importing yfinance #2093

FX196 opened this issue Oct 21, 2024 · 10 comments

Comments

@FX196
Copy link
Contributor

FX196 commented Oct 21, 2024

Describe bug

Syntax error in screener with Python 3.10. Error is coming from https://github.com/ranaroussi/yfinance/blob/main/yfinance/screener/screener.py#L101

Simple code that reproduces your problem

import yfinance

using Python 3.10

Debug log

No debug logs but have stack trace of the import error

Traceback (most recent call last):
  File "/home/runner/work/.../libs.py", line 2, in <module>
    import yfinance as yf
  File "/home/runner/work/.../venv/lib/python3.10/site-packages/yfinance/__init__.py", line 30, in <module>
    from .screener.screener import Screener
  File "/home/runner/work/.../venv/lib/python3.10/site-packages/yfinance/screener/__init__.py", line 1, in <module>
    from .screener import Screener
  File "/home/runner/work/.../venv/lib/python3.10/site-packages/yfinance/screener/screener.py", line 101
    logger.error(f"Failed to get screener data for '{self._body.get('query', "query not set")}' reason: {e}")
                                                                              ^^^^^
SyntaxError: f-string: unmatched '('
Error: Process completed with exit code 1.

Bad data proof

No response

yfinance version

0.2.45

Python version

3.10

Operating system

No response

@sing-tam
Copy link

sing-tam commented Oct 21, 2024

same issue here, need to install previous version to resolve the issue

@mrimahajan
Copy link

Can we take some action on this asap. This is impacting the daily production jobs for us.

@FX196
Copy link
Contributor Author

FX196 commented Oct 21, 2024

Can we take some action on this asap. This is impacting the daily production jobs for us.

@mrimahajan you can pin your version to the previous release by changing your requirements.txt to say yfinance==0.2.44. That's what I did to fix mine

@ValueRaider
Copy link
Collaborator

ValueRaider commented Oct 21, 2024

I'm confused how from .screener import Screener is causing Screener._fetch_and_parse() to execute. It shouldn't be executing on import. I can't reproduce (Linux + Python 3.12).

@ericpien

@fled-dev
Copy link

Same issue

System Details

  • MacOS 15.1
  • Python 3.11.9

@mm3509
Copy link

mm3509 commented Oct 21, 2024

Same problem here, and this bug arises during import.

@ericpien
Copy link
Contributor

I was able to reproduce by testing on Python 3.11, while it was not reproducible in my dev environment (Mac + Python 3.12). It must be related to https://docs.python.org/3/whatsnew/3.12.html#pep-701-syntactic-formalization-of-f-strings in which Quote reuse was enabled for f-strings in 3.12.

But it's bad code anyway - sorry for the inconvenience. Thanks @FX196 for the fix!

@srepollock
Copy link

The fix has been merged in. Is a new release being created?

@ValueRaider
Copy link
Collaborator

Fix merged and released.

Is there a simple action/workflow we can add to avoid a repeat? Ideally not running all the unit tests because that involves dozens of fetches.

@vwbusguy
Copy link

vwbusguy commented Oct 21, 2024

The updated release fixed this for our builds. Many thanks to everyone for the quick report, PR, testing, and merge! This was a textbook example of open source community awesomeness.

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

No branches or pull requests

9 participants