Skip to content

Commit 54db626

Browse files
committed
pylint missed 'lib/*.py' files
1 parent c8408e7 commit 54db626

8 files changed

+206
-202
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repos:
1010
hooks:
1111
- id: black
1212
- repo: https://github.com/pycqa/pylint
13-
rev: pylint-2.7.1
13+
rev: v2.9.3
1414
hooks:
1515
- id: pylint
1616
name: pylint

.pylintrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ confidence=
5050
# --enable=similarities". If you want to run only the classes checker, but have
5151
# no Warning level messages displayed, use"--disable=all --enable=classes
5252
# --disable=W"
53-
# disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call
5453
disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,
5554
long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,
5655
raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,
@@ -65,7 +64,7 @@ disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax
6564
filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,
6665
rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,
6766
deprecated-string-function,deprecated-str-translate-call,import-error,bad-continuation,
68-
subprocess-run-check
67+
subprocess-run-check,too-many-lines
6968

7069
# Enable the message, report, category or checker with the given id(s). You can
7170
# either give multiple identifier separated by comma (,) or put this option

adabot/circuitpython_libraries.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
# of Github API repository object state).
8888
default_validators = [
8989
vals
90-
for vals in inspect.getmembers(cirpy_lib_vals.library_validator)
90+
for vals in inspect.getmembers(cirpy_lib_vals.LibraryValidator)
9191
if vals[0].startswith("validate")
9292
]
9393

@@ -138,7 +138,7 @@ def run_library_checks(validators, kw_args, error_depth):
138138
new_libs = {}
139139
updated_libs = {}
140140

141-
validator = cirpy_lib_vals.library_validator(
141+
validator = cirpy_lib_vals.LibraryValidator(
142142
validators, bundle_submodules, latest_pylint, **kw_args
143143
)
144144
for repo in repos:

adabot/lib/assign_hacktober_label.py

Lines changed: 53 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
# THE SOFTWARE.
2222

23+
"""An utility to automatically apply the 'hacktoberfest' label to open issues
24+
marked as 'good first issue', during DigitalOcean's/GitHub's Hacktoberfest
25+
event.
26+
"""
27+
2328
import argparse
2429
import datetime
2530
import requests
@@ -33,7 +38,13 @@
3338
"--remove-label",
3439
action="store_true",
3540
help="Option to remove Hacktoberfest labels, instead of adding them.",
36-
dest="remove_label",
41+
dest="remove_labels",
42+
)
43+
cli_args.add_argument(
44+
"--dry-run",
45+
action="store_true",
46+
help="Option to remove Hacktoberfest labels, instead of adding them.",
47+
dest="dry_run",
3748
)
3849

3950

@@ -56,7 +67,7 @@ def is_hacktober_season():
5667
]
5768
if add_range[0] <= today <= add_range[1]:
5869
return True, "add"
59-
elif remove_range[0] <= today <= remove_range[1]:
70+
if remove_range[0] <= today <= remove_range[1]:
6071
return True, "remove"
6172

6273
return False, None
@@ -70,7 +81,7 @@ def get_open_issues(repo):
7081
}
7182
response = github.get("/repos/" + repo["full_name"] + "/issues", params=params)
7283
if not response.ok:
73-
print("Failed to retrieve issues for '{}'".format(repo["name"]))
84+
print(f"Failed to retrieve issues for '{repo['name']}'")
7485
return False
7586

7687
issues = []
@@ -79,33 +90,21 @@ def get_open_issues(repo):
7990
[issue for issue in response.json() if "pull_request" not in issue]
8091
)
8192

82-
try:
83-
links = response.headers["Link"]
84-
except KeyError:
85-
break
86-
next_url = None
87-
for link in links.split(","):
88-
link, rel = link.split(";")
89-
link = link.strip(" <>")
90-
rel = rel.strip()
91-
if rel == 'rel="next"':
92-
next_url = link
93-
break
94-
if not next_url:
93+
if response.links.get("next"):
94+
response = requests.get(response.links["next"]["url"])
95+
else:
9596
break
9697

97-
response = requests.get(link, timeout=30)
98-
9998
return issues
10099

101100

102-
def ensure_hacktober_label_exists(repo):
101+
def ensure_hacktober_label_exists(repo, dry_run=False):
103102
"""Checks if the 'Hacktoberfest' label exists on the repo.
104103
If not, creates the label.
105104
"""
106-
response = github.get("/repos/" + repo["full_name"] + "/labels")
105+
response = github.get(f"/repos/{repo['full_name']}/labels")
107106
if not response.ok:
108-
print("Failed to retrieve labels for '{}'".format(repo["name"]))
107+
print(f"Failed to retrieve labels for '{repo['name']}'")
109108
return False
110109

111110
repo_labels = [label["name"] for label in response.json()]
@@ -117,17 +116,16 @@ def ensure_hacktober_label_exists(repo):
117116
"color": "f2b36f",
118117
"description": "DigitalOcean's Hacktoberfest",
119118
}
120-
result = github.post("/repos/" + repo["full_name"] + "/labels", json=params)
121-
if not result.status_code == 201:
122-
print(
123-
"Failed to create new Hacktoberfest label for: {}".format(repo["name"])
124-
)
125-
return False
119+
if not dry_run:
120+
result = github.post(f"/repos/{repo['full_name']}/labels", json=params)
121+
if not result.status_code == 201:
122+
print(f"Failed to create new Hacktoberfest label for: {repo['name']}")
123+
return False
126124

127125
return True
128126

129127

130-
def assign_hacktoberfest(repo, issues=None, remove_labels=False):
128+
def assign_hacktoberfest(repo, issues=None, remove_labels=False, dry_run=False):
131129
"""Gathers open issues on a repo, and assigns the 'Hacktoberfest' label
132130
to each issue if its not already assigned.
133131
"""
@@ -150,50 +148,54 @@ def assign_hacktoberfest(repo, issues=None, remove_labels=False):
150148
update_issue = True
151149
else:
152150
if has_good_first and not has_hacktober:
153-
label_exists = ensure_hacktober_label_exists(repo)
151+
label_exists = ensure_hacktober_label_exists(repo, dry_run)
154152
if not label_exists:
155153
continue
156154
update_issue = True
157155

158156
if update_issue:
159157
params = {"labels": label_names}
160-
result = github.patch(
161-
"/repos/" + repo["full_name"] + "/issues/" + str(issue["number"]),
162-
json=params,
163-
)
164-
165-
if result.ok:
166-
labels_changed += 1
158+
if not dry_run:
159+
result = github.patch(
160+
f"/repos/{repo['full_name']}/issues/{str(issue['number'])}",
161+
json=params,
162+
)
163+
164+
if result.ok:
165+
labels_changed += 1
166+
else:
167+
# sadly, GitHub will only silently ignore labels that are
168+
# not added and return a 200. so this will most likely only
169+
# trigger on endpoint/connection failures.
170+
print(f"Failed to add Hacktoberfest label to: {issue['url']}")
167171
else:
168-
# sadly, GitHub will only silently ignore labels that are
169-
# not added and return a 200. so this will most likely only
170-
# trigger on endpoint/connection failures.
171-
print("Failed to add Hacktoberfest label to: {}".format(issue["url"]))
172+
labels_changed += 1
172173

173174
return labels_changed
174175

175176

176-
def process_hacktoberfest(repo, issues=None, remove_labels=False):
177-
result = assign_hacktoberfest(repo, issues, remove_labels)
177+
def process_hacktoberfest(repo, issues=None, remove_labels=False, dry_run=False):
178+
"""Run hacktoberfest functions and return the result."""
179+
result = assign_hacktoberfest(repo, issues, remove_labels, dry_run)
178180
return result
179181

180182

181183
if __name__ == "__main__":
182-
labels_assigned = 0
184+
LABELS_ASSIGNED = 0
183185
args = cli_args.parse_args()
184186

185-
remove_labels = args.remove_label
186-
187-
if not remove_labels:
187+
if not args.remove_labels:
188188
print("Checking for open issues to assign the Hacktoberfest label to...")
189189
else:
190190
print("Checking for open issues to remove the Hacktoberfest label from...")
191191

192192
repos = common_funcs.list_repos()
193-
for repo in repos:
194-
labels_assigned += process_hacktoberfest(repo, remove_labels)
193+
for repository in repos:
194+
LABELS_ASSIGNED += process_hacktoberfest(
195+
repository, remove_labels=args.remove_labels, dry_run=args.dry_run
196+
)
195197

196-
if not remove_labels:
197-
print("Added the Hacktoberfest label to {} issues.".format(labels_assigned))
198+
if not args.remove_labels:
199+
print(f"Added the Hacktoberfest label to {LABELS_ASSIGNED} issues.")
198200
else:
199-
print("Removed the Hacktoberfest label from {} issues.".format(labels_assigned))
201+
print(f"Removed the Hacktoberfest label from {LABELS_ASSIGNED} issues.")

adabot/lib/blinka_funcs.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,20 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
# THE SOFTWARE.
2222

23+
"""Common functions used with Adabot & Blinka interactions."""
24+
2325
from adabot import github_requests as github
2426

2527

2628
def board_count():
2729
"""Retrieve the number of boards currently supported by Adafruit_Blinka,
2830
via the count of files in circuitpython-org/_blinka.
2931
"""
30-
board_count = 0
32+
count = 0
3133
cirpy_org_url = "/repos/adafruit/circuitpython-org/contents/_blinka"
3234
response = github.get(cirpy_org_url)
3335
if response.ok:
3436
response_json = response.json()
35-
board_count = len(response_json)
37+
count = len(response_json)
3638

37-
return board_count
39+
return count

0 commit comments

Comments
 (0)