-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fix many, but not all, typing failures #168
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b21299c
to
bd75b60
Compare
Coverage SummaryTotal Project Coverage
Coverage by File
Diff CoverageDiff: origin/main...HEAD, staged and unstaged changes
Summary
Diff Coverage Detailsallspice/apiobject.pyLines 136-144 136 self.allspice_client.logger.info("Successfully created Repository %s " % result["name"])
137 else:
138 self.allspice_client.logger.error(result["message"])
139 raise Exception("Repository not created... (gitea: %s)" % result["message"])
! 140 return Repository.parse_response(self.allspice_client, result)
141
142 def get_repositories(self) -> List["Repository"]:
143 results = self.allspice_client.requests_get_paginated(
144 Organization.ORG_REPOS_REQUEST % self.username Lines 364-372 364 self.allspice_client.logger.info("Successfully created Repository %s " % result["name"])
365 else:
366 self.allspice_client.logger.error(result["message"])
367 raise Exception("Repository not created... (gitea: %s)" % result["message"])
! 368 return Repository.parse_response(self.allspice_client, result)
369
370 def get_repositories(self) -> List["Repository"]:
371 """Get all Repositories owned by this User."""
372 url = f"/users/{self.username}/repos" Lines 1512-1523 1512
1513 def __eq__(self, other):
1514 if not isinstance(other, Comment):
1515 return False
! 1516 return self.repository == other.repository and self.id == other.id
1517
1518 def __hash__(self):
! 1519 return hash(self.repository) ^ hash(self.id)
1520
1521 @classmethod
1522 def request(cls, allspice_client, owner: str, repo: str, id: str) -> "Comment":
1523 return cls._request(allspice_client, {"owner": owner, "repo": repo, "id": id}) Lines 1707-1715 1707 @cached_property
1708 def _fields_for_path(self) -> dict[str, str]:
1709 matches = self.URL_REGEXP.search(self.url)
1710 if not matches:
! 1711 raise ValueError(f"Invalid commit URL: {self.url}")
1712
1713 return {
1714 "owner": matches.group(1),
1715 "repo": matches.group(2), Lines 1733-1741 1733
1734 try:
1735 return cls(value)
1736 except ValueError:
! 1737 return value
1738
1739
1740 class CommitStatus(ReadonlyApiObject):
1741 context: str Lines 1845-1853 1845
1846 def __eq__(self, other):
1847 if not isinstance(other, Issue):
1848 return False
! 1849 return self.repository == other.repository and self.id == other.id
1850
1851 def __hash__(self):
1852 return hash(self.repository) ^ hash(self.id) Lines 2016-2027 2016
2017 def __eq__(self, other):
2018 if not isinstance(other, DesignReview):
2019 return False
! 2020 return self.repository == other.repository and self.id == other.id
2021
2022 def __hash__(self):
! 2023 return hash(self.repository) ^ hash(self.id)
2024
2025 @classmethod
2026 def parse_response(cls, allspice_client, result) -> "DesignReview":
2027 api_object = super().parse_response(allspice_client, result) Lines 2298-2307 2298 id: Optional[int] = None,
2299 ) -> Release:
2300 args = {"owner": owner, "repo": repo, "id": id}
2301 release_response = cls._get_gitea_api_object(allspice_client, args)
! 2302 repository = Repository.request(allspice_client, owner, repo)
! 2303 release = cls.parse_response(allspice_client, release_response, repository)
2304 return release
2305
2306 def commit(self):
2307 args = {"owner": self.repo.owner.name, "repo": self.repo.name, "id": self.id} Lines 2468-2482 2468 def __init__(self, allspice_client):
2469 super().__init__(allspice_client)
2470
2471 def __eq__(self, other):
! 2472 if not isinstance(other, Content):
2473 return False
2474
! 2475 return self.sha == other.sha and self.name == other.name
2476
2477 def __hash__(self):
! 2478 return hash(self.sha) ^ hash(self.name)
2479
2480
2481 Ref = Union[Branch, Commit, str] allspice/baseapiobject.pyLines 7-15 7 except ImportError:
8 from typing import Self
9
10 if TYPE_CHECKING:
! 11 from allspice.allspice import AllSpice
12
13 from .exceptions import MissingEqualityImplementation, ObjectIsInvalid, RawRequestEndpointMissing
14 Lines 36-44 36 @classmethod
37 def request(cls, allspice_client: AllSpice) -> Self:
38 # This never would've worked, so maybe we should remove this function
39 # outright.
! 40 return cls._request(allspice_client)
41
42 @classmethod
43 def _request(cls, allspice_client: AllSpice, args: Mapping) -> Self:
44 result = cls._get_gitea_api_object(allspice_client, args) Lines 51-59 51 if hasattr(cls, "API_OBJECT"):
52 raw_request_endpoint = getattr(cls, "API_OBJECT")
53 return allspice_client.requests_get(raw_request_endpoint.format(**args))
54 else:
! 55 raise RawRequestEndpointMissing()
56
57 @classmethod
58 def parse_response(cls, allspice_client: AllSpice, result: Mapping) -> Self:
59 # allspice_client.logger.debug("Found api object of type %s (id: %s)" % (type(cls), id)) allspice/utils/list_components.pyLines 217-225 217
218 if variant is not None:
219 if variant_details is None:
220 # This should never happen, but mypy doesn't know that.
! 221 raise ValueError(f"Variant {variant} not found in PrjPcb file.")
222
223 components = _apply_variations(components, variant_details, allspice_client.logger)
224
225 return components allspice/utils/netlist_generation.pyLines 53-61 53 allspice_client.logger.info(f"Generating netlist for {repository.name=} on {ref=}")
54 allspice_client.logger.info(f"Fetching {pcb_file=}")
55
56 if isinstance(pcb_file, Content):
! 57 pcb_file_path = pcb_file.path
58 else:
59 pcb_file_path = pcb_file
60
61 pcb_components = _extract_all_pcb_components( |
McRaeAlex
approved these changes
Jul 31, 2024
kdumontnu
approved these changes
Jul 31, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a first pass at making this project type-checkable, and fixes much of the "low-hanging fruit" type errors. A few bugs were also discovered during this process and have been fixed.
Notes: