fastai / nbdev

Create delightful software with Jupyter Notebooks
https://nbdev.fast.ai/
Apache License 2.0
4.8k stars 484 forks source link

add support for 3.11 #1373

Closed deven367 closed 8 months ago

deven367 commented 8 months ago

hello, I'm trying to add support for py3.11 for nbdev, I'm trying some stuff on my fork. The PR will also eventually close #1372.

I had a question for @jph00, there's only one test case which fails for 3.11 which is in showdoc. This has only come into existence because the docstring for the Enum was changed in 3.11. How should I try to handle the test case in such a situation? The test case is listed below,

AssertionError                            Traceback (most recent call last)
Cell In[1], line 2
      1 e = enum.Enum('e', 'a b')
----> 2 test_eq(str(show_doc(e)), '---\n\n### e\n\n>      e (value, names=None, module=None, qualname=None, type=None, start=1)\n\nAn enumeration.')

File ~/mambaforge/envs/fun/lib/python3.11/site-packages/fastcore/test.py:37, in test_eq(a, b)
     35 def test_eq(a,b):
     36     "`test` that `a==b`"
---> 37     test(a,b,equals, cname='==')

File ~/mambaforge/envs/fun/lib/python3.11/site-packages/fastcore/test.py:27, in test(a, b, cmp, cname)
     25 "`assert` that `cmp(a,b)`; display inputs and `cname or cmp.__name__` if it fails"
     26 if cname is None: cname=cmp.__name__
---> 27 assert cmp(a,b),f"{cname}:\n{a}\n{b}"

AssertionError: ==:
---

### e

>      e (value, names=None, module=None, qualname=None, type=None, start=1,
>         boundary=None)

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

- attribute access::

>>> Color.RED
<Color.RED: 1>

- value lookup:

>>> Color(1)
<Color.RED: 1>

- name lookup:

>>> Color['RED']
<Color.RED: 1>

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3

>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own
attributes -- see the documentation for details.
---

### e

>      e (value, names=None, module=None, qualname=None, type=None, start=1)

An enumeration.
jph00 commented 8 months ago

Message ID: @.***>Thanks for looking into this. I guess the best thing to do is to just find the bit of the repr that it consistent, and have the test confirm that is correct.

deven367 commented 8 months ago

I think even that won't be possible. They've changed the entire docstring and they've even added a new arg (boundary=None) to the Enum class.

# new in 3.11
e (value, names=None, module=None, qualname=None, type=None, start=1, boundary=None)
Create a collection of name/value pairs.

# in previous versions
e (value, names=None, module=None, qualname=None, type=None, start=1)
An enumeration.
jph00 commented 8 months ago

Message ID: @.***>OK maybe just get rid of that test then...

deven367 commented 8 months ago

Will do!

review-notebook-app[bot] commented 8 months ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

deven367 commented 8 months ago

@jph00 It's ready for review.

jph00 commented 8 months ago

Thank you!