File: fake_module_with_warnings.py

package info (click to toggle)
astroid 4.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,132 kB
  • sloc: python: 38,560; makefile: 24
file content (22 lines) | stat: -rw-r--r-- 661 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'''
This is a mock of a module like Pandas, which can throw warnings for deprecated attributes
'''
import warnings


def __dir__():
    # GH43028
    # Int64Index etc. are deprecated, but we still want them to be available in the dir.
    # Remove in Pandas 2.0, when we remove Int64Index etc. from the code base.
    return list(globals().keys()) + ["Float64Index"]


def __getattr__(name):
    if name == "Float64Index":
        warnings.warn("This is what pandas would do", FutureWarning, stacklevel=2)
        return 5
    raise AttributeError(f"module 'pandas' has no attribute '{name}'")


__all__ = ["Float64Index"]  # pylint: disable=E0603
__doc__ = ""