Skip to content

python: mypy version bump - #56274

Merged
adk3798 merged 5 commits into
ceph:mainfrom
phlogistonjohn:jjm-mypy-bump
Mar 27, 2024
Merged

adk3798 merged 5 commits into
ceph:mainfrom
phlogistonjohn:jjm-mypy-bump

Conversation

@phlogistonjohn

@phlogistonjohn phlogistonjohn commented Mar 18, 2024 •

Copy link
Copy Markdown
Contributor

NOTE: This is a draft initially because, despited being "done", I only have tried it locally. I know the ci env is quite different from mine. Once I'm certain this doesn't interfere with normal make check (and other) jobs in the CI I'll move it out of draft.

In PR #55255 I updated various files to be valid on newer versions of
mypy. Update the constrains file to specify mypy 1.1.1. This certainly
is not the newest version of mypy, but because ceph uses various older
versions of python I am being cautious and trying to only incrementally
update the mypy version. This version fixed an issue or two I hit while
working on a prototype manager module compared to the previous version
in the mypy-constrains.txt file.

In addition, I am cleaning some small mypy and related annoyances I bumped into while working on a new mgr module in the src/pybind/mgr tox.ini file.

Lastly, there's a commit in here that's a duplicate of one in #55068 . I did this because the python versions on my local machine default to versions that fail without the change. Depending on which PR is merged first I will end up dropping it from the other.

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
    • Testing tool configuration updates
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
    • I'm open to suggestions
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate. I'm confident on this one!
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows
  • jenkins test rook e2e

@phlogistonjohn

Copy link
Copy Markdown
Contributor Author

Failure:

      self = <snap_schedule.tests.fs.test_schedule.TestSchedule object at 0x7f50f2d200d0>
simple_schedule = <snap_schedule.fs.schedule.Schedule object at 0x7f50bc379900>

    def test_created_now(self, simple_schedule):
        now = datetime.datetime.now(datetime.timezone.utc)
>       assert simple_schedule.created.minute == now.minute
E       assert 18 == 19
E        +  where 18 = datetime.datetime(2024, 3, 18, 21, 18, 59, 999804, tzinfo=datetime.timezone.utc).minute
E        +    where datetime.datetime(2024, 3, 18, 21, 18, 59, 999804, tzinfo=datetime.timezone.utc) = <snap_schedule.fs.schedule.Schedule object at 0x7f50bc379900>.created
E        +  and   19 = datetime.datetime(2024, 3, 18, 21, 19, 0, 299, tzinfo=datetime.timezone.utc).minute

snap_schedule/tests/fs/test_schedule.py:65: AssertionError

Looks unrelated to my changes.

      mypy: OK ✔ in 1 minute 46.71 seconds

Mypy was ok.

Will rerun make check later to see if the failure was transient.

@phlogistonjohn

Copy link
Copy Markdown
Contributor Author

jenkins test make check

Tests that touch this enum fail for me locally but pass in the CI. This
seems to be due to new enum related behavior in Python 3.11.
See: https://blog.pecar.me/python-enum
Instead of fixing it as suggested in the above blog, adding a __str__
method works on all python versions I care to know about.

Signed-off-by: John Mulligan <[email protected]>
In PR ceph#55255 I updated various files to be valid on newer versions of
mypy. Update the constrains file to specify mypy 1.1.1. This certainly
is not the newest version of mypy, but because ceph uses various older
versions of python I am being cautious and trying to only incrementally
update the mypy version. This version fixed an issue or two I hit while
working on a prototype manager module compared to the previous version
in the mypy-constrains.txt file.

Signed-off-by: John Mulligan <[email protected]>
tox supports automatically running tools with different python versions
if you name your envs properly. Continue to permit the use of `mypy` as
an env (as the default) but also allow a selection of python
versions like `py38-mypy`.

Signed-off-by: John Mulligan <[email protected]>
In the tox.ini file the modules validated by mypy are explicitly listed.
Fix one item which was indented differently than the others.
Sort the list.

Signed-off-by: John Mulligan <[email protected]>
@phlogistonjohn

Copy link
Copy Markdown
Contributor Author

jenkins test api

@phlogistonjohn
phlogistonjohn marked this pull request as ready for review March 20, 2024 14:34
@phlogistonjohn
phlogistonjohn requested a review from a team as a code owner March 20, 2024 14:34
Comment thread src/pybind/mgr/tox.ini


[testenv:mypy]
[testenv:{,py37-,py38-,py39-,py310-}mypy]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be clear, this gives us the ability to run something like tox -e py37-mypy, but by default we'll still just run mypy?

@phlogistonjohn phlogistonjohn Mar 20, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. tox supports expansions like those of bash. So {,py37-,py38-,py39-,py310-}mypy expands to mypy, py37-mypy, py38-mypy, py39-mypy, py310-mypy. I got lazy and didn't figure we'd need anything newer than 3.10 for now.

@adk3798

adk3798 commented Mar 26, 2024

Copy link
Copy Markdown
Contributor

https://pulpito.ceph.com/adking-2024-03-26_01:50:53-orch:cephadm-wip-adk-testing-2024-03-25-1628-distro-default-smithi/

Other than the in cluster log stuff, 4 failures were the mds upgrade sequence which is known to fail currently, and the test_cephadm task, which failed with https://tracker.ceph.com/issues/65155

Nothing to block merging the PRs in the run

@adk3798

adk3798 commented Mar 26, 2024

Copy link
Copy Markdown
Contributor

jenkins test api

1 similar comment
@phlogistonjohn

Copy link
Copy Markdown
Contributor Author

jenkins test api

@adk3798
adk3798 merged commit d82c9aa into ceph:main Mar 27, 2024
@phlogistonjohn
phlogistonjohn deleted the jjm-mypy-bump branch March 27, 2024 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants