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

posonly arguments support #54

Closed
sobolevn opened this issue Mar 14, 2020 · 1 comment
Closed

posonly arguments support #54

sobolevn opened this issue Mar 14, 2020 · 1 comment

Comments

@sobolevn
Copy link
Contributor

This code does not raise any violations:

def some(list, /, arg): 
    ...

Because / posonly args are not checked.
It is a thing since 3.8

I will send a PR after #52 is merged

@sobolevn
Copy link
Contributor Author

sobolevn commented Mar 14, 2020

Turns out we also don't support kwonly arguments. I will add it to this fix.

This is for the history

Here's how ast of this simple function looks like:

def some(a, /, b, *, c, d=True):
    ...

Structure:

<_ast.Module>
  ├─ type_ignores: []
  └─ body
      └─ [0] <_ast.FunctionDef>
          ├─ lineno: 1
          ├─ col_offset: 0
          ├─ end_col_offset: 7
          ├─ end_lineno: 2
          ├─ name: 'some'
          ├─ returns: None
          ├─ type_comment: None
          ├─ decorator_list: []
          ├─ body
          │   └─ [0] <_ast.Expr>
          │       ├─ lineno: 2
          │       ├─ col_offset: 4
          │       ├─ end_col_offset: 7
          │       ├─ end_lineno: 2
          │       └─ value: <_ast.Constant>
          │           ├─ lineno: 2
          │           ├─ col_offset: 4
          │           ├─ end_col_offset: 7
          │           ├─ end_lineno: 2
          │           ├─ kind: None
          │           └─ value: Ellipsis
          └─ args: <_ast.arguments>
              ├─ kwarg: None
              ├─ vararg: None
              ├─ defaults: []
              ├─ args
              │   └─ [0] <_ast.arg>
              │       ├─ lineno: 1
              │       ├─ col_offset: 15
              │       ├─ annotation: None
              │       ├─ arg: 'b'
              │       ├─ end_col_offset: 16
              │       ├─ end_lineno: 1
              │       └─ type_comment: None
              ├─ kw_defaults
              │   ├─ [0] <builtins.NoneType>
              │   │   └─ None
              │   └─ [1] <_ast.Constant>
              │       ├─ lineno: 1
              │       ├─ col_offset: 26
              │       ├─ end_col_offset: 30
              │       ├─ end_lineno: 1
              │       ├─ kind: None
              │       └─ value: True
              ├─ kwonlyargs
              │   ├─ [0] <_ast.arg>
              │   │   ├─ lineno: 1
              │   │   ├─ col_offset: 21
              │   │   ├─ annotation: None
              │   │   ├─ arg: 'c'
              │   │   ├─ end_col_offset: 22
              │   │   ├─ end_lineno: 1
              │   │   └─ type_comment: None
              │   └─ [1] <_ast.arg>
              │       ├─ lineno: 1
              │       ├─ col_offset: 24
              │       ├─ annotation: None
              │       ├─ arg: 'd'
              │       ├─ end_col_offset: 25
              │       ├─ end_lineno: 1
              │       └─ type_comment: None
              └─ posonlyargs
                  └─ [0] <_ast.arg>
                      ├─ lineno: 1
                      ├─ col_offset: 9
                      ├─ annotation: None
                      ├─ arg: 'a'
                      ├─ end_col_offset: 10
                      ├─ end_lineno: 1
                      └─ type_comment: None

gforcada added a commit that referenced this issue Mar 16, 2020
Adds kwonly and posonly args support, closes #54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant