Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Ruff Rule: Remove unneeded occurrences of the global keyword #10232

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2c429dd
refactored files for ruff rule PLW0602 compliance
techy4shri Dec 28, 2024
1925a77
formatted by black
techy4shri Dec 28, 2024
28e140b
changing type hinting and type definition
techy4shri Dec 30, 2024
1b1c439
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 30, 2024
4a09bf5
Removing ruff rule error and fixing function
techy4shri Dec 31, 2024
adca5bc
squashing commits# This is a combination of 2 commits.
pre-commit-ci[bot] Dec 30, 2024
28b0fd9
Merge branch '10196/refactor/re-enable-ruff-rules' of github.com:tech…
techy4shri Dec 31, 2024
e5c702b
removed type definition errors and mypy errors
techy4shri Jan 2, 2025
d7b0477
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 2, 2025
036112d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 30, 2024
a97c961
Removing ruff rule error and fixing function
techy4shri Dec 31, 2024
3802459
removed type definition errors and mypy errors
techy4shri Jan 2, 2025
ae50d2f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 2, 2025
43bfcc1
Merge branch '10196/refactor/re-enable-ruff-rules' of github.com:tech…
techy4shri Jan 2, 2025
335f69c
Update update.py with noqa comment to pass pytest
techy4shri Jan 2, 2025
fc6296b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 2, 2025
6a8152d
updating files as per review to check
techy4shri Jan 2, 2025
b6f8d09
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 2, 2025
f44577e
add noqa statement
RayBB Jan 3, 2025
bbfcc07
restore open syllabus project file
RayBB Jan 3, 2025
1156155
Merge branch 'master' into 10196/refactor/re-enable-ruff-rules
RayBB Jan 3, 2025
26f831a
remove extra line
RayBB Jan 3, 2025
9b9646a
Merge branch 'internetarchive:master' into 10196/refactor/re-enable-r…
techy4shri Jan 4, 2025
7f0e139
Merge branch 'master' into 10196/refactor/re-enable-ruff-rules
techy4shri Jan 8, 2025
3d431e6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 8, 2025
61ee525
Update openlibrary/utils/open_syllabus_project.py
cdrini Jan 15, 2025
6b95051
enable ruff rule
RayBB Jan 15, 2025
2bd7854
enable ruff rule
RayBB Jan 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions openlibrary/core/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ def create_stats_client(cfg=config):

def put(key, value, rate=1.0):
"Records this ``value`` with the given ``key``. It is stored as a millisecond count"
global client

if client:
pystats_logger.debug(f"Putting {value} as {key}")
client.timing(key, value, rate)


def increment(key, n=1, rate=1.0):
"Increments the value of ``key`` by ``n``"
global client

if client:
pystats_logger.debug("Incrementing %s" % key)
for i in range(n):
Expand All @@ -62,7 +62,7 @@ def gauge(key: str, value: int, rate: float = 1.0) -> None:

See https://statsd.readthedocs.io/en/v3.3/types.html#gauges
"""
global client

if client:
pystats_logger.debug(f"Updating gauge {key} to {value}")
client.gauge(key, value, rate=rate)
Expand Down
4 changes: 2 additions & 2 deletions openlibrary/plugins/openlibrary/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
def evaluate_and_store_stat(name, stat, summary):
"""Evaluates whether the given statistic is to be recorded and if
so, records it."""
global filters

if not summary:
return
try:
Expand Down Expand Up @@ -133,7 +133,7 @@ def process_stats(stats):


def register_filter(name, function):
global filters

filters[name] = function


Expand Down
5 changes: 0 additions & 5 deletions openlibrary/plugins/upstream/borrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ class borrow_status(delegate.page):
path = "(/books/.*)/_borrow_status"

def GET(self, key):
global lending_subjects

i = web.input(callback=None)

Expand Down Expand Up @@ -521,7 +520,6 @@ def get_loan_status(resource_id: str):
}
]
"""
global loanstatus_url

if not loanstatus_url:
raise Exception('No loanstatus_url -- cannot check loan status')
Expand Down Expand Up @@ -551,7 +549,6 @@ def get_loan_status(resource_id: str):

def get_all_loaned_out():
"""Returns array of BSS status for all resources currently loaned out (according to BSS)"""
global loanstatus_url

if not loanstatus_url:
raise Exception('No loanstatus_url -- cannot check loan status')
Expand Down Expand Up @@ -614,7 +611,6 @@ def _update_loan_status(loan_key, loan, bss_status=None) -> None:

def update_loan_from_bss_status(loan_key, loan, status) -> None:
"""Update the loan status in the private data store from BSS status"""
global loan_fulfillment_timeout_seconds

if not resource_uses_bss(loan['resource_id']):
raise Exception(
Expand Down Expand Up @@ -669,7 +665,6 @@ def update_all_loan_status() -> None:

def resource_uses_bss(resource_id: str) -> bool:
"""Returns true if the resource should use the BSS for status"""
global acs_resource_id_prefixes

if resource_id:
for prefix in acs_resource_id_prefixes:
Expand Down
1 change: 0 additions & 1 deletion openlibrary/solr/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

@functools.cache
def get_solr_updaters() -> list[AbstractSolrUpdater]:
global data_provider
assert data_provider is not None
return [
# ORDER MATTERS
Expand Down
1 change: 0 additions & 1 deletion openlibrary/utils/open_syllabus_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def get_osp_dump_location() -> Path | None:
"""
Get whether the location of the Open Syllabus project counts dump
"""
global osp_dump_location
return osp_dump_location


Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ ignore = [
"F841",
"PERF401",
"PIE790",
"PLW0602",
"PLW0603",
"PLW2901",
"RUF001",
Expand Down
1 change: 0 additions & 1 deletion scripts/partner_batch_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ class Biblio:
VU VY VZ WA WC WI WL WM WP WT WX XL XZ ZF ZZ""".split()

def __init__(self, data):
global required_fields
self.REQUIRED_FIELDS = required_fields

self.primary_format = data[6]
Expand Down
1 change: 0 additions & 1 deletion scripts/solr_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ async def update_keys(keys):
return 0

# FIXME: Some kind of hack introduced to work around DB connectivity issue
global args
logger.debug("Args: %s" % str(args))
update.load_configs(args['ol_url'], args['ol_config'], 'default')

Expand Down
Loading