Repository: python/bedevere (python)

Issue:
Add docs label for PRs that touch Doc/tools/.nitignore
See e.g. https://github.com/python/cpython/pull/114280 or https://github.com/python/cpython/pull/114194

Pull request description:
Add the "docs" label also for Doc/*/.nitignore
Closes #616

Patch:
diff --git a/bedevere/prtype.py b/bedevere/prtype.py
index 0105e50..bccd879 100644
--- a/bedevere/prtype.py
+++ b/bedevere/prtype.py
@@ -43,7 +43,7 @@ async def classify_by_filepaths(gh, pull_request, filenames):
         if util.is_news_dir(filename):
             news = True
         filepath = pathlib.PurePath(filename)
-        if filepath.suffix == ".rst":
+        if filepath.suffix == ".rst" or filepath.name == ".nitignore":
             docs = True
         elif filepath.name.startswith("test_"):
             tests = True


Test patch:
diff --git a/tests/test_prtype.py b/tests/test_prtype.py
index 4fcaf0c..c9b0777 100644
--- a/tests/test_prtype.py
+++ b/tests/test_prtype.py
@@ -85,6 +85,26 @@ async def test_docs_no_news():
     assert gh.post_data[0] == [Labels.docs.value, Labels.skip_news.value]
 
 
+async def test_docs_no_news_with_dotnitignore():
+    filenames = {"path/to/docs1.rst", "path/to/.nitignore"}
+    issue = {"labels": [], "labels_url": "https://api.github.com/some/label"}
+    gh = FakeGH(getitem=issue)
+    event_data = {
+        "action": "opened",
+        "number": 1234,
+        "pull_request": {
+            "url": "https://api.github.com/repos/cpython/python/pulls/1234",
+            "statuses_url": "https://api.github.com/some/status",
+            "issue_url": "https://api.github.com/repos/cpython/python/issue/1234",
+        },
+    }
+    await prtype.classify_by_filepaths(gh, event_data["pull_request"], filenames)
+    assert gh.getitem_url == "https://api.github.com/repos/cpython/python/issue/1234"
+    assert len(gh.post_url) == 1
+    assert gh.post_url[0] == "https://api.github.com/some/label"
+    assert gh.post_data[0] == [Labels.docs.value, Labels.skip_news.value]
+
+
 async def test_docs_and_news():
     filenames = {"/path/to/docs1.rst", f"Misc/NEWS.d/next/Lib/{GOOD_BASENAME}"}
     issue = {"labels": [], "labels_url": "https://api.github.com/some/label"}