danielcweeks commented on code in PR #7519:
URL: https://github.com/apache/iceberg/pull/7519#discussion_r1185262156
##########
python/pyiceberg/catalog/rest.py:
##########
@@ -172,8 +175,6 @@ class OAuthErrorResponse(IcebergBaseModel):
class RestCatalog(Catalog):
uri: str
- session: Session
Review Comment:
I'll update since it appears we're using this elsewhere, but the behavior
around this is very strange.
The class attribute needs to be initialized when declaring it as a class
attribute. Without initialization, it doesn't exist:
```python
>>> class A:
... attr: str
... def print_attr(self):
... print(self.attr)
>>> a = A()
>>> a.print_attr()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Input In [3], in <cell line: 1>()
----> 1 a.print_attr()
Input In [14], in A.print_attr(self)
3 def print_attr(self):
----> 4 print(self.attr)
AttributeError: 'A' object has no attribute 'attr'
>>> A.attr
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Input In [4], in <cell line: 1>()
----> 1 A.attr
AttributeError: type object 'A' has no attribute 'attr'
```
If you initialize in the constructor, then it behaves the same as an
instance attribute (not as a class attribute). Alternatively, it you
initialize at the class attribute level, then any assignment elsewhere will
result in switching the class behavior to an instance behavior (which can
produce some very strange behavior).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]