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
dbt==0.20.1 commands break on python 3.9.7 #3843
Comments
|
Can confirm, I faced the same issue. I wonder if it's this change in the Python 3.9.7 release causing the breakage?
The IANAPG (I Am Not A Python Guru) so I'm mostly just guessing though! |
|
Surprised there are not more people here... EDIT: Confirmed that pinning to Python 3.9.6 solved the issue. All credit to the linked Slack thread above! |
|
I'm having the same issue in a different code base. I feel confident the change linked in the issue body are the problem, but I don't understand the I created this minimal example: from dataclasses import dataclass
from typing import Protocol
class P(Protocol):
pass
@dataclass
class B(P):
value: str
print(B("test"))In Traceback (most recent call last):
File "test.py", line 11, in <module>
print(B("test"))
TypeError: B() takes no argumentsIn B(value='test') |
|
Thanks for jumping into this one, everyone! And thanks for opening the python issue, @julianfortune. I'm not yet sure whether this represents:
|
|
As a temporary workaround you can patch if sys.version_info >= (3, 9, 7):
import dataclasses
original_set_new_attr = dataclasses._set_new_attribute
def patched_set_new_attr(cls, name, value):
if (
name == '__init__'
and any(getattr(c, '_is_protocol', False) for c in cls.__bases__)
and cls.__init__ is object.__init__
):
del cls.__init__
return original_set_new_attr(cls, name, value)
dataclasses._set_new_attribute = patched_set_new_attr |
|
@uriyyo Thank you for the workaround, the fix, and a new test case to prevent the regression in the future! |
|
@julianfortune it's not clear, is it possible to fix the issue now by upgrading dbt or python 3.9 ? Or are we waiting for either dbt or python one to make a new public release ? If I want to patch manually, where can I find dataclasses._set_new_attribute ? I'm not used to patching classes in python, where can I drop the patch ? |
|
@Startouf -- the latest patch release of dbt implements a workaround (#3855), so you can upgrade |
Many dbt commands (dbt run, dbt test, ...) are breaking on Python 3.9.7 released yesterday: https://docs.python.org/release/3.9.7/whatsnew/changelog.html.
Here is a traceback:
For more details please see the following Slack thread: https://getdbt.slack.com/archives/C99SNSRTK/p1630506829031300
The text was updated successfully, but these errors were encountered: