Skip to content

fix: issue #216 - #217

Closed
thorwhalen wants to merge 1 commit into
neithere:masterfrom
thorwhalen:master
Closed

thorwhalen wants to merge 1 commit into
neithere:masterfrom
thorwhalen:master

Conversation

@thorwhalen

Copy link
Copy Markdown

Replaced

 if args and (args[0] in cls.BASIC_TYPES):

with

 if args and (args[0] in cls.BASIC_TYPES):

Replaced 

```python
 if args and (args[0] in cls.BASIC_TYPES):
```

with

```python
 if args and (args[0] in cls.BASIC_TYPES):
```
@neithere

Copy link
Copy Markdown
Owner

Hi @thorwhalen, thank you for the report and the fix!

Could you please provide a minimal example to repro the bug? It would be great to update the unit tests along with the fix.

@neithere neithere added the bug label Jan 15, 2024
@neithere neithere added this to the 0.31.1 milestone Jan 15, 2024
@thorwhalen

Copy link
Copy Markdown
Author

Hi @thorwhalen, thank you for the report and the fix!

Could you please provide a minimal example to repro the bug? It would be great to update the unit tests along with the fix.

from typing import Optional, List

def func(x: Optional[List] = None):
        return 'hello'

if __name__ == '__main__':
    import argh

    argh.dispatch_command(func)

@thorwhalen

Copy link
Copy Markdown
Author

Hi @thorwhalen, thank you for the report and the fix!
Could you please provide a minimal example to repro the bug? It would be great to update the unit tests along with the fix.

from typing import Optional, List

def func(x: Optional[List] = None):
        return 'hello'

if __name__ == '__main__':
    import argh

    argh.dispatch_command(func)

Given this, perhaps my PR is not the right fix. Perhaps it's something to do with Optional[List] in particular (I tried Optional[Tuple] and it doesn't give me the same problem.

Note: I'm on python 3.10.13, on a mac.

@neithere

neithere commented Jan 16, 2024 •

Copy link
Copy Markdown
Owner

Aha, thanks, got it! Optional[list] or list | None works but Optional[List] is broken. I'll take a closer look soon.

P.S.: if you don't need to support older Pythons, you can simply replace List with list.

@neithere

Copy link
Copy Markdown
Owner

Thank you Thor, the final fix was indeed a bit different (see 8f270d0) but your effort and your example have helped me pinpoint the exact problem and solve it there. Will ship the fix in 0.31.1 today.

@neithere neithere closed this Jan 19, 2024
@thorwhalen

Copy link
Copy Markdown
Author

Great. Thanks. I'll update to 0.31.1 now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants