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

Sim w/o global session (Sourcery refactored) #7

Open
wants to merge 1 commit into
base: simulation-no-global
Choose a base branch
from

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Apr 12, 2023

Pull Request #6 refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the simulation-no-global branch, then run:

git fetch origin sourcery/simulation-no-global
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

Comment on lines -49 to +52
else:
bind = Bind.get_instance(bind_name)
bind = Bind.get_instance(bind_name)

with create_session(bind) as session:
return func(*args, session=session, **kwargs)
with create_session(bind) as session:
return func(*args, session=session, **kwargs)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function provide_session refactored with the following changes:

Comment on lines -56 to -59
dto = self._session.scalars(self._query.filter_by(uuid=entity_id)).one_or_none()
if not dto:
if dto := self._session.scalars(
self._query.filter_by(uuid=entity_id)
).one_or_none():
return Entity(dto)
else:
raise NotFound(entity_id)
return Entity(dto)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ORMRepository.get refactored with the following changes:

Comment on lines -149 to +151
execute_options = values["execution_options"].dict(exclude_defaults=True)
if execute_options:
if execute_options := values["execution_options"].dict(
exclude_defaults=True
):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function EngineConfig.scrub_execution_options refactored with the following changes:

Comment on lines -48 to +58
[isinstance(arg, (sa.orm.Session, sa.ext.asyncio.AsyncSession)) for arg in args]
isinstance(arg, (sa.orm.Session, sa.ext.asyncio.AsyncSession))
for arg in args
)
session_in_kwargs = "session" in kwargs
session_provided = session_in_args or session_in_kwargs

if session_provided:
return func(self, *args, **kwargs)
else:
session = session_proxy()
session = session_proxy()

return func(self, session, *args, **kwargs)
return func(self, session, *args, **kwargs)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function provide_global_contextual_session refactored with the following changes:

initialize = False if config is None else True
initialize = config is not None
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function QuartSQLAlchemy.__init__ refactored with the following changes:

Comment on lines -164 to +163
"User duplication for email: {} (client_id: {})".format(
email,
client_id,
),
f"User duplication for email: {email} (client_id: {client_id})"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AuthUser.add_by_email_and_client_id refactored with the following changes:

Comment on lines -206 to +199
"New auth user (id: {}) created by (client_id: {})".format(row.id, client_id),
f"New auth user (id: {row.id}) created by (client_id: {client_id})"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AuthUser.add_by_client_id refactored with the following changes:

Comment on lines -412 to +405
new_row = self._repository.add(
return self._repository.add(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AuthWallet.add refactored with the following changes:

Comment on lines -444 to +435
if not row:
return None

return one(row)
return one(row) if row else None
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AuthWallet.get_by_public_address refactored with the following changes:

Comment on lines -473 to +461
if not rows:
return []

return rows
return rows or []
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AuthWallet.get_by_auth_user_id refactored with the following changes:

if order_by_clause is not None:
order_by_clause = (order_by_clause,)
else:
order_by_clause = ()

order_by_clause = (order_by_clause, ) if order_by_clause is not None else ()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function RepositoryLegacyAdapter.get_by refactored with the following changes:

Comment on lines -132 to +128
for group in group_by:
selectables.append(group.expression)

selectables.extend(group.expression for group in group_by)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function RepositoryLegacyAdapter.count_by refactored with the following changes:

Comment on lines -181 to -189
results = self._adapted.select(
yield from self._adapted.select(
session,
conditions=filters,
options=[sa.orm.selectinload(getattr(self.model, attr)) for attr in join_list],
options=[
sa.orm.selectinload(getattr(self.model, attr))
for attr in join_list
],
include_inactive=allow_inactive,
yield_by_chunk=chunk_size,
)
for result in results:
yield result
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function RepositoryLegacyAdapter.yield_by_chunk refactored with the following changes:

Comment on lines -246 to +241
if sqla_model:
return result
return self.model_schema.from_orm(result)
return result if sqla_model else self.model_schema.from_orm(result)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function insert refactored with the following changes:

Comment on lines -269 to +262
if sqla_model:
return existing
return self.model_schema.from_orm(existing)
return existing if sqla_model else self.model_schema.from_orm(existing)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function update refactored with the following changes:

error_code = values.get("error_code")
if error_code:
return "failed"
return "ok"
return "failed" if (error_code := values.get("error_code")) else "ok"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ResponseWrapper.set_status_by_error_code refactored with the following changes:

return hash(tuple([self._encoded_id, self._decoded_id]))
return hash((self._encoded_id, self._decoded_id))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ObjectID.__hash__ refactored with the following changes:

if isinstance(value, int):
return value
else:
return self.hashids.decode(value)[0]
return value if isinstance(value, int) else self.hashids.decode(value)[0]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ObjectID._decode refactored with the following changes:

db = QuartSQLAlchemy(app=app)

yield db
yield QuartSQLAlchemy(app=app)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SimpleTestBase.db refactored with the following changes:

Comment on lines -166 to +164
db = QuartSQLAlchemy(app=app)

yield db
yield QuartSQLAlchemy(app=app)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function MixinTestBase.db refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants