Skip to content

Commit

Permalink
Fix new B039 error in flake8-bugbear 24.8.19
Browse files Browse the repository at this point in the history
  • Loading branch information
nsoranzo committed Aug 30, 2024
1 parent d1fc599 commit 236765d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
10 changes: 5 additions & 5 deletions lib/galaxy/dependencies/pinned-lint-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
attrs==23.2.0
flake8==7.1.0
flake8-bugbear==24.4.26
attrs==24.2.0
flake8==7.1.1
flake8-bugbear==24.8.19
mccabe==0.7.0
pycodestyle==2.12.0
pycodestyle==2.12.1
pyflakes==3.2.0
ruff==0.6.1
ruff==0.6.3
7 changes: 3 additions & 4 deletions lib/galaxy/model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
# of a request (which run within a threadpool) to see changes to the ContextVar
# state. See https://github.com/tiangolo/fastapi/issues/953#issuecomment-586006249
# for details
_request_state: Dict[str, str] = {}
REQUEST_ID = ContextVar("request_id", default=_request_state.copy())
REQUEST_ID: ContextVar[Union[Dict[str, str], None]] = ContextVar("request_id", default=None)


@contextlib.contextmanager
Expand Down Expand Up @@ -112,12 +111,12 @@ def new_session(self):

def request_scopefunc(self):
"""
Return a value that is used as dictionary key for sqlalchemy's ScopedRegistry.
Return a value that is used as dictionary key for SQLAlchemy's ScopedRegistry.
This ensures that threads or request contexts will receive a single identical session
from the ScopedRegistry.
"""
return REQUEST_ID.get().get("request") or threading.get_ident()
return REQUEST_ID.get({}).get("request") or threading.get_ident()

@staticmethod
def set_request_id(request_id):
Expand Down

0 comments on commit 236765d

Please sign in to comment.