-
Notifications
You must be signed in to change notification settings - Fork 170
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
[BUG] deprecated_kwargs
(list[str]) in v0.24 raises type object not subscriptable error
#1200
Comments
Python 3.8 doesn't directly support this syntax.
Currently janitor is trying to compat with multi-environments. |
Fully understood as it is as I expected. |
deprecated_kwargs
(list[str]) in v0.24 raises type object not subscriptable error
I'm wondering whether this issue should be reopened? PyPI and the GitHub README specify Python >= 3.6, so not being unable to |
May I know how to make this work for python 3.8? I tried adding this line on the top of my import block but got Input In [13]
from __future__ import __annotations__
^
SyntaxError: future feature __annotations__ is not defined BTW, I tried |
@xujiboy my mistake |
Thanks @Zeroto521 I tried |
@xujiboy only for py3.8, lower versions don't support this feature. $ python
Python 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 05:59:00) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> a: list[int] = [1, 2]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'type' object is not subscriptable
>>> from __future__ import annotations
>>> a: list[int] = [1, 2]
>>> a
[1, 2] |
Thanks @Zeroto521 for providing the example. I am able to reproduce your code snipt but Python 3.8.13 (default, Oct 21 2022, 23:50:54)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from __future__ import annotations
In [2]: a: list[str] = ['2', ]
In [3]: import janitor
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Input In [3], in <cell line: 1>()
----> 1 import janitor
File ~/miniconda3/envs/eda/lib/python3.8/site-packages/janitor/__init__.py:9, in <module>
5 import lazy_loader as lazy
8 from .accessors import * # noqa: F403, F401
----> 9 from .functions import * # noqa: F403, F401
10 from .io import * # noqa: F403, F401
11 from .math import * # noqa: F403, F401
File ~/miniconda3/envs/eda/lib/python3.8/site-packages/janitor/functions/__init__.py:19, in <module>
1 """
2 # General Functions
3
(...)
15 7. Never import utils.
16 """
---> 19 from .add_columns import add_columns
20 from .also import also
21 from .bin_numeric import bin_numeric
File ~/miniconda3/envs/eda/lib/python3.8/site-packages/janitor/functions/add_columns.py:3, in <module>
1 import pandas_flavor as pf
----> 3 from janitor.utils import check, deprecated_alias
4 import pandas as pd
5 from typing import Union, List, Any, Tuple
File ~/miniconda3/envs/eda/lib/python3.8/site-packages/janitor/utils.py:216, in <module>
207 if not func(df, *args, **kwargs) == func(
208 func(df, *args, **kwargs), *args, **kwargs
209 ):
210 raise ValueError(
211 "Supplied function is not idempotent for the given DataFrame."
212 )
215 def deprecated_kwargs(
--> 216 *arguments: list[str],
217 message: str = (
218 "The keyword argument '{argument}' of '{func_name}' is deprecated."
219 ),
220 error: bool = True,
221 ) -> Callable:
222 """
223 Used as a decorator when deprecating function's keyword arguments.
224
(...)
244 keyword arguments. # noqa: DAR402
245 """
247 def decorator(func):
TypeError: 'type' object is not subscriptable Is this reproducible on your end? Or are you able to |
@Zeroto521 thanks for the prompt response. So it's my understanding that if currently I want to consume pyjanitor 0.24 through pypi, I need to use python 3.9+. If I have to stick with python 3.8 then I need to install the mentioned branch locally. |
Yes, as you said. For Python version, I prefer to use the latest version 3.11. And this issue will be fixed at pyjanitor 0.24.1 |
Brief Description
The addition of deprecated_kwargs in version 0.23 causes a type object not subscriptable error.
System Information
I'm using Python 3.8.12 on a sagemaker instance. I'm pretty sure this is the issue, that my company has us locked at 3.8.12 right now. Selecting the v.0.23 does solve the problem.
I'm sorry if this isn't enough information at the moment, let me know if you need anything else.
Error
The text was updated successfully, but these errors were encountered: