-
Notifications
You must be signed in to change notification settings - Fork 122
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
Attribute code
has type str
but is used as type None
#878
Conversation
"filename": "tests/extensions/test_grid.py" "warning_type": "Incompatible attribute type [8]" "warning_message": " Attribute `code` declared in class `GridExtension` has type `str` but is used as type `None`." "warning_line": 89 "fix": None to ""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a false positive -- the code
property returns Optional[str]
:
pystac/pystac/extensions/grid.py
Lines 68 to 71 in 69fcf3f
@property | |
def code(self) -> Optional[str]: | |
"""Get or sets the latitude band of the datasource.""" | |
return self._get_property(CODE_PROP, str) |
Codecov Report
@@ Coverage Diff @@
## main #878 +/- ##
==========================================
- Coverage 94.32% 94.30% -0.02%
==========================================
Files 83 83
Lines 11963 11963
Branches 1403 1403
==========================================
- Hits 11284 11282 -2
- Misses 496 497 +1
- Partials 183 184 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Thanks, for the answer, but I think it is not the method call in line 89. |
Thanks, I misunderstood what was going on. It looks like the line you're trying to fix is intentionally triggering a diff --git a/pystac/extensions/grid.py b/pystac/extensions/grid.py
index 928897e..3b0bd6f 100644
--- a/pystac/extensions/grid.py
+++ b/pystac/extensions/grid.py
@@ -17,7 +17,7 @@ CODE_REGEX: str = r"[A-Z]+-[-_.A-Za-z0-9]+"
CODE_PATTERN: Pattern[str] = re.compile(CODE_REGEX)
-def validated_code(v: str) -> str:
+def validated_code(v: Optional[str]) -> str:
if not isinstance(v, str):
raise ValueError("Invalid Grid code: must be str")
if not CODE_PATTERN.fullmatch(v):
@@ -71,7 +71,7 @@ class GridExtension(
return self._get_property(CODE_PROP, str)
@code.setter
- def code(self, v: str) -> None:
+ def code(self, v: Optional[str]) -> None:
self._set_property(CODE_PROP, validated_code(v), pop_if_none=False)
@classmethod Requesting Phil's review since he added this in #799. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment
Related Issue(s): #
Type error found with Pyre
Description:
"filename": "tests/extensions/test_grid.py"
"warning_type": "Incompatible attribute type [8]"
"warning_message": " Attribute
code
declared in classGridExtension
has typestr
but is used as typeNone
.""warning_line": 89
"fix": None to ""