| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| use_pr: Optional[PullRequest] = None | ||
| for pr in repo.get_pulls(): | ||
| if pr.head.sha == event.workflow_run.head_commit.id: | ||
| use_pr = pr | ||
| break | ||
| use_pr: Optional[PullRequest] = next( | ||
| ( | ||
| pr | ||
| for pr in repo.get_pulls() | ||
| if pr.head.sha == event.workflow_run.head_commit.id | ||
| ), | ||
| None, | ||
| ) | ||
|
|
There was a problem hiding this comment.
Lines 45-49 refactored with the following changes:
Sorry, something went wrong.
| notified = False | ||
| for pr_comment in pr_comments: | ||
| if message in pr_comment.body: | ||
| notified = True | ||
| notified = any(message in pr_comment.body for pr_comment in pr_comments) | ||
| logging.info(f"Docs preview was notified: {notified}") | ||
| if not notified: | ||
| artifact_name = f"docs-zip-{commit}" | ||
| use_artifact: Optional[Artifact] = None | ||
| for artifact in artifacts_response.artifacts: | ||
| if artifact.name == artifact_name: | ||
| use_artifact = artifact | ||
| break | ||
| use_artifact: Optional[Artifact] = next( | ||
| ( | ||
| artifact | ||
| for artifact in artifacts_response.artifacts | ||
| if artifact.name == artifact_name | ||
| ), | ||
| None, | ||
| ) | ||
|
|
Sorry, something went wrong.
| ): | ||
| heroes = session.exec(select(Hero).offset(offset).limit(limit)).all() | ||
| return heroes | ||
| return session.exec(select(Hero).offset(offset).limit(limit)).all() |
There was a problem hiding this comment.
Function read_heroes refactored with the following changes:
Sorry, something went wrong.
| with Session(engine) as session: | ||
| heroes = session.exec(select(Hero).offset(offset).limit(limit)).all() | ||
| return heroes | ||
| return session.exec(select(Hero).offset(offset).limit(limit)).all() |
There was a problem hiding this comment.
Function read_heroes refactored with the following changes:
Sorry, something went wrong.
| with Session(engine) as session: | ||
| heroes = session.exec(select(Hero).offset(offset).limit(limit)).all() | ||
| return heroes | ||
| return session.exec(select(Hero).offset(offset).limit(limit)).all() |
There was a problem hiding this comment.
Function read_heroes refactored with the following changes:
Sorry, something went wrong.
| with Session(engine) as session: | ||
| heroes = session.exec(select(Hero).offset(offset).limit(limit)).all() | ||
| return heroes | ||
| return session.exec(select(Hero).offset(offset).limit(limit)).all() |
There was a problem hiding this comment.
Function read_heroes refactored with the following changes:
Sorry, something went wrong.
| relationship_info = RelationshipInfo( | ||
| return RelationshipInfo( | ||
| back_populates=back_populates, | ||
| link_model=link_model, | ||
| sa_relationship=sa_relationship, | ||
| sa_relationship_args=sa_relationship_args, | ||
| sa_relationship_kwargs=sa_relationship_kwargs, | ||
| ) | ||
| return relationship_info |
There was a problem hiding this comment.
Function Relationship refactored with the following changes:
Sorry, something went wrong.
| def __init__( | ||
| cls, classname: str, bases: Tuple[type, ...], dict_: Dict[str, Any], **kw: Any | ||
| ) -> None: | ||
| def __init__(self, classname: str, bases: Tuple[type, ...], dict_: Dict[str, Any], **kw: Any) -> None: |
There was a problem hiding this comment.
Function SQLModelMetaclass.__init__ refactored with the following changes:
Sorry, something went wrong.
| foreign_key = getattr(field.field_info, "foreign_key", None) | ||
| if foreign_key: | ||
| if foreign_key := getattr(field.field_info, "foreign_key", None): |
There was a problem hiding this comment.
Function get_column_from_field refactored with the following changes:
Sorry, something went wrong.
| if getattr(self.__config__, "table", False): | ||
| if is_instrumented(self, name): | ||
| set_attribute(self, name, value) | ||
| if getattr(self.__config__, "table", False) and is_instrumented( | ||
| self, name | ||
| ): | ||
| set_attribute(self, name, value) |
There was a problem hiding this comment.
Function SQLModel.__setattr__ refactored with the following changes:
Sorry, something went wrong.
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.80%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
Sorry, something went wrong.
| if not getattr(cls.__config__, "table", False): | ||
| # If not table, normal Pydantic code | ||
| m: _TSQLModel = cls.__new__(cls) | ||
| else: | ||
| # If table, create the new instance normally to make SQLAlchemy create | ||
| # the _sa_instance_state attribute | ||
| m = cls() | ||
| m = cls() if getattr(cls.__config__, "table", False) else cls.__new__(cls) |
There was a problem hiding this comment.
Function SQLModel.from_orm refactored with the following changes:
This removes the following comments ( why? ):
# the _sa_instance_state attribute # If table, create the new instance normally to make SQLAlchemy create # If not table, normal Pydantic code
Sorry, something went wrong.
| if include is None and exclude is None and exclude_unset is False: | ||
| if include is None and exclude is None and not exclude_unset: |
There was a problem hiding this comment.
Function SQLModel._calculate_keys refactored with the following changes:
This removes the following comments ( why? ):
# Updated to not return SQLAlchemy attributes # recursion, or traversing the whole database # Original in Pydantic: # | self.__sqlmodel_relationships__.keys() # keys = self.__dict__.keys() # Do not include relationships as that would easily lead to infinite
Sorry, something went wrong.
| def __tablename__(cls) -> str: | ||
| return cls.__name__.lower() | ||
| def __tablename__(self) -> str: | ||
| return self.__name__.lower() |
There was a problem hiding this comment.
Function SQLModel.__tablename__ refactored with the following changes:
Sorry, something went wrong.
| if not isinstance(query_cache_size, _DefaultPlaceholder): | ||
| current_kwargs["query_cache_size"] = query_cache_size | ||
| current_kwargs.update(kwargs) | ||
| current_kwargs |= kwargs |
There was a problem hiding this comment.
Function create_engine refactored with the following changes:
Sorry, something went wrong.
| if not isinstance(value, uuid.UUID): | ||
| return f"{uuid.UUID(value).int:x}" | ||
| else: | ||
| # hexstring | ||
| return f"{value.int:x}" | ||
| return ( | ||
| f"{value.int:x}" | ||
| if isinstance(value, uuid.UUID) | ||
| else f"{uuid.UUID(value).int:x}" | ||
| ) |
There was a problem hiding this comment.
Function GUID.process_bind_param refactored with the following changes:
This removes the following comments ( why? ):
# hexstring
Sorry, something went wrong.
| value2 = Default("bar") | ||
|
|
||
| assert not (value1 == value2) | ||
| assert value1 != value2 |
There was a problem hiding this comment.
Function test_not_equality refactored with the following changes:
Sorry, something went wrong.
| value2 = "foo" | ||
|
|
||
| assert not (value1 == value2) | ||
| assert value1 != "foo" |
There was a problem hiding this comment.
Function test_not_equality_other refactored with the following changes:
Sorry, something went wrong.
| # Now that this item was checked, remove it from the list | ||
| calls.pop(calls.index(call)) | ||
| assert len(calls) == 0, "The list should only have the expected items" | ||
| assert not calls, "The list should only have the expected items" |
There was a problem hiding this comment.
Function test_tutorial refactored with the following changes:
Sorry, something went wrong.
| # Now that this item was checked, remove it from the list | ||
| calls.pop(calls.index(call)) | ||
| assert len(calls) == 0, "The list should only have the expected items" | ||
| assert not calls, "The list should only have the expected items" |
There was a problem hiding this comment.
Function test_tutorial refactored with the following changes:
Sorry, something went wrong.
| # Now that this item was checked, remove it from the list | ||
| calls.pop(calls.index(call)) | ||
| assert len(calls) == 0, "The list should only have the expected items" | ||
| assert not calls, "The list should only have the expected items" |
There was a problem hiding this comment.
Function test_tutorial refactored with the following changes:
Sorry, something went wrong.
perf: raise exception if no matching sqlalchemy type
| Back | FazBrowse Home | New Git URL |
Branch main refactored by Sourcery.
If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locallyReduce the feedback loop during development by using the Sourcery editor plugin:
- VS Code
- PyCharm
Review changes via command lineTo manually merge these changes, make sure you're on the main branch, then run:
Help us improve this pull request!