Skip to content

Commit

Permalink
style: fix a few pylint alerts
Browse files Browse the repository at this point in the history
I think pylint hasn't been run here in a very long time.  This removes
pep8 which isn't called correctly, and fixes a few actual issues in
modules I've touched recently.
  • Loading branch information
Ned Batchelder authored and nedbat committed Jul 26, 2023
1 parent 2dc7322 commit 170c895
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 21 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,5 @@ upgrade: $(COMMON_CONSTRAINTS_TXT) ## update the requirements/*.txt files with
pip-compile --upgrade -o requirements/development.txt requirements/development.in
for fextra in edx_repo_tools/*/extra.in; do pip-compile --upgrade -o $${fextra%.in}.txt $$fextra; done

lint: ## run pep8 and pylint
pep8 || true
pylint *.py edx_repo_tools tests || true
lint: ## run pylint
pylint *.py edx_repo_tools tests
6 changes: 3 additions & 3 deletions barcalendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ def years_months(self):
for (m = 0; m < 12; m++) {{
sheet.getRange({monthrow}, {iyear}+m).setValue("JFMAMJJASOND"[m]);
}}
""");
""")
print(f"""\
sheet.getRange({yearrow}, 1, 1, {self.width})
.setFontWeight("bold")
.setHorizontalAlignment("center");
sheet.getRange({monthrow}, 1, 1, {self.width})
.setHorizontalAlignment("center");
""");
""")
print(f"""\
var rules = sheet.getConditionalFormatRules();
rules.push(
Expand Down Expand Up @@ -275,7 +275,7 @@ def get_defaults_from_tutor():
def parse_version_number(line):
"""
Get version number in line from YAML file.
Note that this only captures major and minor version (not patch number).
Note that this only captures major and minor version (not patch number).
e.g. "docker.io/elasticsearch:7.17.9" -> "7.17"
"""
match = re.search(r'(?P<version_number>\d+(\.\d+)?)', line)
Expand Down
3 changes: 1 addition & 2 deletions edx_repo_tools/conventional_commits/commitstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

import csv
import datetime
import fnmatch
import os
import os.path
Expand Down Expand Up @@ -56,7 +55,7 @@ def load_commits(db, repo_name):
commit_table = db["commits"]

log = get_cmd_output(GITLOG)
for i, commit in enumerate(log.split(SEP + "\n")):
for commit in log.split(SEP + "\n"):
if re.match(r"fatal: your current branch '\w+' does not have any commits yet", commit):
# Project-only or uninitialized repos are like this.
continue
Expand Down
2 changes: 1 addition & 1 deletion edx_repo_tools/find_dependencies/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Run it with a list of local repo directories. It will traverse into each direct

- second_party_urls.txt is the subset of repo_urls.txt that come from organizations close enough to the Open edX project, that the repos might need to be moved into the openedx organization.

I run it in a tree of all repos, with these commands to example all the repos branched for Olive::
I run it in a tree of all repos, with these commands to examine all the repos branched for Olive::

$ export OLIVE_DIRS=$(gittreeif origin/open-release/olive.master -q pwd)
$ find_dependencies $OLIVE_DIRS
Expand Down
2 changes: 1 addition & 1 deletion edx_repo_tools/find_dependencies/find_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def find_py_reqs():
if possible_req.exists():
return possible_req
if any(Path(ind).exists() for ind in PY_INDICATORS):
print(f"WARNING: {repo_name} is likely a Python package, but we can't find its dependencies.")
print(f"WARNING: {os.getcwd()} is likely a Python package, but we can't find its dependencies.")
return None


Expand Down
10 changes: 5 additions & 5 deletions edx_repo_tools/repo_access_scraper/repo_access_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ def screenshot_pages(page, url, image_prefix):
page.screenshot(path=f"{IMAGES_DIR}/{image_prefix}-{imgnum}.png", full_page=True)

# If there's a next page, visit it.
next = page.locator("a.next_page")
if next.count():
next_page = page.locator("a.next_page")
if next_page.count():
with page.expect_navigation():
next.click()
next_page.click()
else:
# No next page, we're done here.
break
Expand All @@ -72,7 +72,7 @@ def request_list(url):
"""
data = []
while url:
resp = requests.get(url, headers=HEADERS)
resp = requests.get(url, headers=HEADERS, timeout=60)
data.extend(resp.json())
url = None
if "link" in resp.headers:
Expand All @@ -84,7 +84,7 @@ def request_list(url):

def request_dict(url):
"""Get dict data from a GitHub URL."""
return requests.get(url, headers=HEADERS).json()
return requests.get(url, headers=HEADERS, timeout=60).json()

def counted(things: list, thing_name: str) -> str:
"""
Expand Down
4 changes: 2 additions & 2 deletions edx_repo_tools/repo_checks/repo_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,9 +817,9 @@ def _update_branch_protection(self, params):
"https://api.github.com"
+ self.api.repos.update_branch_protection.path.format(**params)
)
resp = requests.put(
resp = requests.put( # pylint: disable=missing-timeout
url, headers=headers, json=params
) # pylint: disable=missing-timeout
)

resp.raise_for_status()

Expand Down
1 change: 0 additions & 1 deletion requirements/development.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
-r base.txt

edx-lint
pep8
pip-tools
pytest
pytest-mock
Expand Down
2 changes: 0 additions & 2 deletions requirements/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,6 @@ path-py==12.5.0
# via -r requirements/base.txt
pbr==5.11.1
# via stevedore
pep8==1.7.1
# via -r requirements/development.in
pip-tools==7.0.0
# via -r requirements/development.in
platformdirs==3.9.1
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def is_requirement(line):
# To run tests & linting across the entire repo, we need to install the union
# of *all* extra requirements lists *plus* the dev-specific requirements.
# If this list contains conflicting pins, then installing it will fail;
# that is intentional.
# that is intentional.
EXTRAS_REQUIRE["dev"] = sorted({
*load_requirements("requirements/development.txt"),
*(extra_pin for extra_reqs in EXTRAS_REQUIRE.values() for extra_pin in extra_reqs),
Expand Down

0 comments on commit 170c895

Please sign in to comment.