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

DeprecationWarning regarding the use of LegacyVersion #612

Closed
jtilahun opened this issue Mar 31, 2023 · 5 comments
Closed

DeprecationWarning regarding the use of LegacyVersion #612

jtilahun opened this issue Mar 31, 2023 · 5 comments
Labels
Awaiting Response Waiting for response

Comments

@jtilahun
Copy link

Describe the bug
The below DeprecationWarning appears since installing pandas-stubs:

07:59:41.56 [WARN] /home/jtilahun/.cache/pants/setup/bootstrap-Linux-x86_64/2.15.0_py38/lib/python3.8/site-packages/pkg_resources/_vendor/packaging/specifiers.py:255: DeprecationWarning: Creating a LegacyVersion has been deprecated and will be removed in the next major release
  warnings.warn(

To Reproduce

  1. Install pandas-stubs via pip by running pip install pandas-stubs from within the virtual environment.
  2. Run a Python test. Using the Pants build system, this can be done as shown below:
$ ./pants test ops/utils/rpc_utils_test.py
07:59:41.56 [WARN] /home/jtilahun/.cache/pants/setup/bootstrap-Linux-x86_64/2.15.0_py38/lib/python3.8/site-packages/pkg_resources/_vendor/packaging/specifiers.py:255: DeprecationWarning: Creating a LegacyVersion has been deprecated and will be removed in the next major release
  warnings.warn(

07:59:47.18 [INFO] Completed: Run Pytest - ops/utils/rpc_utils_test.py:tests - succeeded.
Partition: ops_unit_tests

✓ ops/utils/rpc_utils_test.py:tests succeeded in 5.38s.

Wrote test reports to dist/test_results

Please complete the following information:

  • OS: Linux
  • OS Version Ubuntu 20.04
  • python version 3.8.10
  • version of type checker pyright 1.1.295
  • version of installed pandas-stubs pandas-stubs 1.5.3.230321

Additional context
I never saw this warning prior to installing pandas-stubs, but this warning shows up constantly now. It's difficult to trace the contents of the warning message directly to pandas-stubs though.

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Mar 31, 2023

We'd need a simple test case in order to replicate.

Looking at where the warning comes from, it might be due to how we specify the dependencies of pandas-stubs and how that specification interacts with pants. But in order to investigate, we'd have to be able to replicate this.

@Dr-Irv Dr-Irv added the Awaiting Response Waiting for response label Mar 31, 2023
@jtilahun
Copy link
Author

The simplest test case is in fact a stub unit test as shown below:

import unittest


class Test(unittest.TestCase):
    def test(self):
        self.assertTrue(True)

with the stub test saved as test.py and the test target declared in BUILD.pants as:

python_test(
    name="test",
    source="test.py",
)

Running ./pants test on this Python test suffices to make the warning appear:

$ ./pants test ops/utils:test
10:24:58.81 [WARN] /home/jtilahun/.cache/pants/setup/bootstrap-Linux-x86_64/2.15.0_py38/lib/python3.8/site-packages/pkg_resources/_vendor/packaging/specifiers.py:255: DeprecationWarning: Creating a LegacyVersion has been deprecated and will be removed in the next major release
  warnings.warn(

10:24:58.85 [INFO] Completed: Run Pytest - ops/utils:test - succeeded.
Partition: ops_unit_tests

✓ ops/utils:test succeeded in 1.58s (memoized).

Wrote test reports to dist/test_results

I think the warning is emitted during the stage where Pants is doing its resolution, because it looks like the warning appears before Pytest is even invoked.

@twoertwein
Copy link
Member

You could probably run python -Werror .... to get a trace of where the warning is coming from.

@jtilahun
Copy link
Author

jtilahun commented Apr 1, 2023

Hmm, there was actually a typo in requirements.txt. Changing

pandas-stubs>=1.5.3<2.0.0

to

pandas-stubs>=1.5.3,<2.0.0

in requirements.txt and regenerating constraints appears to make the warning go away. Having said this, I'm unsure of how a typo in requirements.txt leads to a DeprecationWarning of all things. The constraints generation did not complain when the typo was present, which confuses me. Is there an actual deprecation present somewhere or is this a misleading warning? If there is an actual deprecation, the deprecation should still be addressed. However, if there are actually no deprecations, I guess that this may be simply be a case of a warning being misleading.

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Apr 1, 2023

Based on this issue in pants pantsbuild/pants#17848, I think this is what happened. Nothing to do with pandas-stubs. Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Response Waiting for response
Projects
None yet
Development

No branches or pull requests

3 participants