Repository: asottile/dead

Issue:
Support posonlyargs
they are notably missing in [this code](https://github.com/asottile/dead/blob/8817aa412121e319fc45dd5e269b0d009e7c2c06/dead.py#L133-L140)

Discussion:

Patch:
diff --git a/dead.py b/dead.py
index 5b3fdbc..a9f48c0 100644
--- a/dead.py
+++ b/dead.py
@@ -131,6 +131,7 @@ class Visitor(ast.NodeVisitor):
         with self.scope():
             if not self._is_stub_function(node):
                 for arg in (
+                        *getattr(node.args, 'posonlyargs', ()),
                         *node.args.args,
                         node.args.vararg,
                         *node.args.kwonlyargs,


Test patch:
diff --git a/tests/dead_test.py b/tests/dead_test.py
index 73aa8b2..9de3213 100644
--- a/tests/dead_test.py
+++ b/tests/dead_test.py
@@ -1,4 +1,5 @@
 import subprocess
+import sys
 
 import pytest
 
@@ -247,3 +248,16 @@ def test_ignored_arguments(git_dir):
     )
     subprocess.check_call(('git', 'add', '.'))
     assert not dead.main(())
+
+
+@pytest.mark.xfail(sys.version_info < (3, 8), reason='py38+')
+def test_unused_positional_only_argument(git_dir, capsys):  # pragma: no cover
+    git_dir.join('f.py').write(
+        'def f(unused, /):\n'
+        '    return 1\n'
+        'print(f)\n',
+    )
+    subprocess.check_call(('git', 'add', '.'))
+    assert dead.main(())
+    out, _ = capsys.readouterr()
+    assert out == 'unused is never read, defined in f.py:1\n'