Skip to content

Conversation

@harshil21
Copy link
Member

@harshil21 harshil21 commented Jul 23, 2022

Tests if py 3.11 works with the lib or not (the Python team really wants everyone to test it out). Not to be merged atm.

Also changes:

  • Made str(StringEnum) & str(IntEnum) return consistent across python versions
  • Also modify IntEnum's __repr__ to match StringEnum's

@harshil21
Copy link
Member Author

3.11 tests are failing due to python/cpython#94601, which has been fixed and will be included in 3.11b5. Built docs locally without any issues.

@harshil21 harshil21 added the 🔗 python related technology: python label Jul 24, 2022
@harshil21
Copy link
Member Author

So the root cause of the bug might not have been the issue I linked, but the changed behavior when mixing str and Enum in py3.11. See https://docs.python.org/3.11/library/enum.html#notes.

Hence I adjusted the behavior for 3.11. Also noticed that we show the Enum value on __repr__ for IntEnum derived classes. Is that intended behavior?

@harshil21 harshil21 marked this pull request as ready for review July 28, 2022 20:47
@harshil21 harshil21 added the 📋 do-not-merge-yet work status: do-not-merge-yet label Jul 28, 2022
@Bibo-Joshi
Copy link
Member

About allowed failures: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idcontinue-on-error

IISC that may lead to some unexpected UI stuff (community/community#15452, actions/runner#2347), but whatever …

Regarding repr, format and str: I think I've changed my perspective a bit by now. Consider the following example

def pprint(arg: int | str) -> str:
    return "Value is" + str(arg)  # explicitly cast in case it's an int

Now pprint(ChatType.PRIVATE) would yield "Value is ChatType.PRIVATE" which I'd argue is unexpected. So I'm now leaning towards having StringEnum == str.__str__. As no user has complained about that so far, I'm also okay with keeping it as is.

In any case

  • StringEnum and IntEnum should behave the same
  • repr should give unambiguous output and hence ChatType.PRIVATE is still derisable here IMO

@harshil21 harshil21 changed the title Beta test python 3.11 Test python 3.11 & Change Enum Behaviour Aug 9, 2022
@harshil21
Copy link
Member Author

Waiting for actions/python-versions#183 to be merged so the 3.11 tests run...

@harshil21 harshil21 added the 🔗 github-actions related technology: github-actions label Aug 9, 2022
@harshil21 harshil21 added the 🛠 refactor change type: refactor label Aug 11, 2022
@harshil21 harshil21 removed the 📋 do-not-merge-yet work status: do-not-merge-yet label Aug 11, 2022
Copy link
Member

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

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

lgtm. rerunning the failing tests (test-official fails b/c of the api update, ofc)

@Bibo-Joshi Bibo-Joshi merged commit 90c0fe9 into master Aug 17, 2022
@Bibo-Joshi Bibo-Joshi deleted the py-3.11-tests branch August 17, 2022 16:24
@github-actions github-actions bot locked and limited conversation to collaborators Aug 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

🔗 github-actions related technology: github-actions 🔗 python related technology: python 🛠 refactor change type: refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants