Skip to content

Commit 3673ea0

Browse files
committed
refactor: follow python EOL schedule.
1 parent 40617d3 commit 3673ea0

7 files changed

Lines changed: 114 additions & 35 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010

1111
strategy:
1212
matrix:
13-
python-version: [3.11, 3.12, 3.13, 3.14]
13+
python-version: [3.10, 3.11, 3.12, 3.13, 3.14]
1414

1515
steps:
1616
- name: Check out code

README.md

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,57 +10,63 @@ Backlog API v2 Client Library for Python
1010
- Python 3.11+
1111
- requests 2.x
1212

13-
# Install
13+
# Usage: install
1414

1515
```
1616
pip install pybacklog
1717
```
1818

19-
# Usage
19+
# Usage: code
2020

2121
```python
2222
from pybacklog import BacklogClient
23+
import os
2324

24-
client = BacklogClient("your_space_name", "your_api_key")
25+
YOUR_SPACE_NAME = os.getenv("BACKLOG_SPACE_NAME", "")
26+
YOUR_API_KEY = os.getenv("BACKLOG_API_KEY", "")
27+
YOUR_PROJECT = os.getenv("BACKLOG_PROJECT", "")
28+
YOUR_ISSUE_KEY = os.getenv("BACKLOG_ISSUE_KEY", "")
29+
30+
client = BacklogClient(YOUR_SPACE_NAME, YOUR_API_KEY)
2531

2632
# space
27-
space = client.do("GET", "space") # GET /api/v2/space
28-
print(space.get(u"spaceKey"))
33+
space = client.space()
34+
print(space.get("spaceKey"))
2935

3036
# project
3137
projects = client.projects()
3238

3339
# activity
34-
activities = client.project_activities("YOUR_PROJECT", {"activityTypeId[]": [1, 2]})
40+
activities = client.project_activities(YOUR_PROJECT, {"activityTypeId[]": [1, 2]})
3541

3642
# list issue
37-
project_id = client.get_project_id("YOUR_PROJECT")
38-
issues = client.issues({"projectId[]":[project_id], "sort": "dueDate"})
43+
project_id = client.get_project_id(YOUR_PROJECT)
44+
issues = client.issues({"projectId[]": [project_id], "sort": "dueDate"})
3945

4046
# specified issue
41-
issue = client.issue("YOUR_PROJECT-999")
47+
issue = client.issue(YOUR_ISSUE_KEY)
4248

4349
# create issue
44-
project_id = client.get_project_id(project_key)
45-
issue_type_id = client.project_issue_types(project_key)[0][u"id"]
46-
priority_id = client.priorities()[0][u"id"]
50+
project_id = client.get_project_id(YOUR_PROJECT)
51+
issue_type_id = client.project_issue_types(YOUR_PROJECT)[0]["id"]
52+
priority_id = client.priorities()[0]["id"]
4753

48-
client.create_issue(project_id,
49-
u"some summary",
50-
issue_type_id,
51-
priority_id,
52-
{"description": u"a is b and c or d."})
54+
if project_id and issue_type_id and priority_id:
55+
client.create_issue(project_id, "some summary", issue_type_id, priority_id, {"description": "a is b and c or d."})
5356

5457
# add comment
55-
client.add_issue_comment("YOUR_PROJECT-999", u"or ... else e.")
58+
client.add_issue_comment(YOUR_ISSUE_KEY, "or ... else e.")
5659

5760
# top 10 star collector
58-
star_collectors = [(client.user_stars_count(u[u"id"], {"since": "2017-06-01", "until": "2017-06-30"})[u"count"], u[u"name"]) for u in client.users()]
61+
star_collectors = [
62+
(client.user_stars_count(u["id"], {"since": "2017-06-01", "until": "2017-06-30"})["count"], u["name"])
63+
for u in client.users()
64+
]
5965
star_collectors.sort()
6066
star_collectors.reverse()
6167

6268
for i, (c, u) in enumerate(star_collectors[:10]):
63-
print(i+1, c, u)
69+
print(i + 1, c, u)
6470
```
6571

6672
supported operations are `pydoc pybacklog.BacklogClient`
@@ -74,16 +80,21 @@ Use `do` or let's write code and Pull Request.
7480

7581
```python
7682
from pybacklog import BacklogClient
83+
import os
84+
85+
YOUR_SPACE_NAME = os.getenv("BACKLOG_SPACE_NAME", "")
86+
YOUR_API_KEY = os.getenv("BACKLOG_API_KEY", "")
87+
YOUR_PROJECT = os.getenv("BACKLOG_PROJECT", "")
7788

78-
client = BacklogClient("your_space_name", "your_api_key")
89+
client = BacklogClient(YOUR_SPACE_NAME, YOUR_API_KEY)
7990
space = client.do("GET", "space") # GET /api/v2/space
80-
projects = client.do("GET", "projects",
81-
query_params={"archived": false}
82-
) # GET /api/v2/projects?archived=false
83-
activities = client.do("GET", "projects/{project_id_or_key}/activities",
84-
url_params={"project_id_or_key": "myproj"},
85-
query_params={"activityTypeId[]": [1, 2]}
86-
) # GET /api/v2/projects/myproj/activities?activityTypeIds%5B%5D=1&activityTypeIds%5B%5D=2
91+
projects = client.do("GET", "projects", query_params={"archived": False}) # GET /api/v2/projects?archived=false
92+
activities = client.do(
93+
"GET",
94+
"projects/{project_id_or_key}/activities",
95+
url_params={"project_id_or_key": YOUR_PROJECT},
96+
query_params={"activityTypeId[]": [1, 2]},
97+
) # GET /api/v2/projects/myproj/activities?activityTypeIds%5B%5D=1&activityTypeIds%5B%5D=2
8798
```
8899

89100
see also [Backlog API Overview \| Backlog Developer API \| Nulab](https://developer.nulab-inc.com/docs/backlog/)

examples/project_activities.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434

3535
try:
3636
summary = activity["content"]["summary"]
37-
except (KeyError, TypeError):
37+
except KeyError:
38+
summary = ""
39+
except TypeError:
3840
summary = ""
3941

4042
item = (created, url, summary)

examples/project_activities2.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626

2727
try:
2828
summary = activity["content"]["summary"]
29-
except (KeyError, TypeError):
29+
except KeyError:
30+
summary = ""
31+
except TypeError:
3032
summary = ""
31-
3233
item = (created, url, summary)
3334
items.append(item)
3435

examples/readme.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from pybacklog import BacklogClient
2+
import os
3+
4+
YOUR_SPACE_NAME = os.getenv("BACKLOG_SPACE_NAME", "")
5+
YOUR_API_KEY = os.getenv("BACKLOG_API_KEY", "")
6+
YOUR_PROJECT = os.getenv("BACKLOG_PROJECT", "")
7+
YOUR_ISSUE_KEY = os.getenv("BACKLOG_ISSUE_KEY", "")
8+
9+
client = BacklogClient(YOUR_SPACE_NAME, YOUR_API_KEY)
10+
11+
# space
12+
space = client.space()
13+
print(space.get("spaceKey"))
14+
15+
# project
16+
projects = client.projects()
17+
18+
# activity
19+
activities = client.project_activities(YOUR_PROJECT, {"activityTypeId[]": [1, 2]})
20+
21+
# list issue
22+
project_id = client.get_project_id(YOUR_PROJECT)
23+
issues = client.issues({"projectId[]": [project_id], "sort": "dueDate"})
24+
25+
# specified issue
26+
issue = client.issue(YOUR_ISSUE_KEY)
27+
28+
# create issue
29+
project_id = client.get_project_id(YOUR_PROJECT)
30+
issue_type_id = client.project_issue_types(YOUR_PROJECT)[0]["id"]
31+
priority_id = client.priorities()[0]["id"]
32+
33+
if project_id and issue_type_id and priority_id:
34+
client.create_issue(project_id, "some summary", issue_type_id, priority_id, {"description": "a is b and c or d."})
35+
36+
# add comment
37+
client.add_issue_comment(YOUR_ISSUE_KEY, "or ... else e.")
38+
39+
# top 10 star collector
40+
star_collectors = [
41+
(client.user_stars_count(u["id"], {"since": "2017-06-01", "until": "2017-06-30"})["count"], u["name"])
42+
for u in client.users()
43+
]
44+
star_collectors.sort()
45+
star_collectors.reverse()
46+
47+
for i, (c, u) in enumerate(star_collectors[:10]):
48+
print(i + 1, c, u)

examples/readme2.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from pybacklog import BacklogClient
2+
import os
3+
4+
YOUR_SPACE_NAME = os.getenv("BACKLOG_SPACE_NAME", "")
5+
YOUR_API_KEY = os.getenv("BACKLOG_API_KEY", "")
6+
YOUR_PROJECT = os.getenv("BACKLOG_PROJECT", "")
7+
8+
client = BacklogClient(YOUR_SPACE_NAME, YOUR_API_KEY)
9+
space = client.do("GET", "space") # GET /api/v2/space
10+
projects = client.do("GET", "projects", query_params={"archived": False}) # GET /api/v2/projects?archived=false
11+
activities = client.do(
12+
"GET",
13+
"projects/{project_id_or_key}/activities",
14+
url_params={"project_id_or_key": YOUR_PROJECT},
15+
query_params={"activityTypeId[]": [1, 2]},
16+
) # GET /api/v2/projects/myproj/activities?activityTypeIds%5B%5D=1&activityTypeIds%5B%5D=2

pyproject.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ authors = [
1313
]
1414
urls = { "Homepage" = "https://github.com/netmarkjp/pybacklog" }
1515
classifiers = [
16+
"Programming Language :: Python :: 3.10",
1617
"Programming Language :: Python :: 3.11",
1718
"Programming Language :: Python :: 3.12",
1819
"Programming Language :: Python :: 3.13",
1920
"Programming Language :: Python :: 3.14",
2021
"Topic :: Utilities"
2122
]
22-
requires-python = ">=3.11, <3.15"
23+
requires-python = ">=3.10, <3.15"
2324

2425
dependencies = [
2526
"requests >=2.12.4,<3.0"
@@ -36,12 +37,12 @@ dev = [
3637
# Additional uv-specific configurations can be added here.
3738

3839
[tool.ruff]
39-
target-version = "py314"
40+
target-version = "py310"
4041
line-length = 120
4142
# lint.select = ["E", "F", "W"]
4243
# lint.ignore = []
4344
exclude = [".venv", "build", "dist", ".eggs", "*.egg-info", ".ruff_cache", "__pycache__"]
4445

4546
[tool.pyright]
46-
pythonVersion = "3.11"
47+
pythonVersion = "3.10"
4748
typeCheckingMode = "strict"

0 commit comments

Comments
 (0)