Skip to content

Commit a20efb0

Browse files
committed
fix: fix docs and quality errors
1 parent 73acadf commit a20efb0

File tree

6 files changed

+29
-23
lines changed

6 files changed

+29
-23
lines changed

xblocks_contrib/annotatable/annotatable.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ class AnnotatableBlock(LegacyXmlMixin, XBlock):
9595
# List of supported highlight colors for annotations
9696
HIGHLIGHT_COLORS = ["yellow", "orange", "purple", "blue", "green"]
9797

98+
@property
99+
def location(self):
100+
return self.scope_ids.usage_id
101+
98102
def _get_annotation_class_attr(self, index, el): # pylint: disable=unused-argument
99103
"""Returns a dict with the CSS class attribute to set on the annotation
100104
and an XML key to delete from the element.
@@ -247,12 +251,12 @@ def workbench_scenarios():
247251
]
248252

249253
@classmethod
250-
def definition_from_xml(cls, xml_object, system): # lint-amnesty, pylint: disable=unused-argument
254+
def definition_from_xml(cls, xml_object, system):
251255
if len(xml_object) == 0 and len(list(xml_object.items())) == 0:
252256
return {'data': ''}, []
253257
return {'data': etree.tostring(xml_object, pretty_print=True, encoding='unicode')}, []
254258

255-
def definition_to_xml(self, resource_fs): # lint-amnesty, pylint: disable=unused-argument
259+
def definition_to_xml(self, resource_fs):
256260
"""
257261
Return an Element if we've kept the import OLX, or None otherwise.
258262
"""
@@ -278,12 +282,12 @@ def definition_to_xml(self, resource_fs): # lint-amnesty, pylint: disable=unuse
278282
# Can't recover here, so just add some info and
279283
# re-raise
280284
lines = self.data.split('\n')
281-
line, offset = err.position
285+
line, offset = err.position # lint-amnesty, pylint: disable=unpacking-non-sequence
282286
msg = (
283287
"Unable to create xml for block {loc}. "
284288
"Context: '{context}'"
285289
).format(
286290
context=lines[line - 1][offset - 40:offset + 40],
287291
loc=self.location,
288292
)
289-
raise SerializationError(self.location, msg) # lint-amnesty, pylint: disable=raise-missing-from
293+
raise SerializationError(self.location, msg) from err

xblocks_contrib/common/xml_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def own_metadata(block: XBlock) -> dict[str, Any]:
132132
keys, mapped to their serialized values
133133
"""
134134
result = {}
135-
for field in block.fields.values(): # lint-amnesty, pylint: disable=no-member
135+
for field in block.fields.values():
136136
if field.scope == Scope.settings and field.is_set_on(block):
137137
try:
138138
result[field.name] = field.read_json(block)

xblocks_contrib/html/html.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def stringify_children(node):
143143
# This makes our block more resilient. It won't crash in test environments
144144
# where the user service might not be available.
145145
@XBlock.wants("user")
146-
class HtmlBlock(LegacyXmlMixin, XBlock): # pylint: disable=abstract-method
146+
class HtmlBlock(LegacyXmlMixin, XBlock):
147147
"""
148148
The HTML XBlock.
149149
"""
@@ -268,7 +268,7 @@ def get_html(self):
268268
data = data.replace("%%COURSE_ID%%", str(self.scope_ids.usage_id.context_key))
269269
return data
270270

271-
def studio_view(self, context=None): # pylint: disable=unused-argument
271+
def studio_view(self, context=None):
272272
"""Return a fragment that contains the html for the studio view."""
273273
# Only the ReactJS editor is supported for this block.
274274
# See https://github.com/openedx/frontend-app-authoring/tree/master/src/editors/containers/TextEditor

xblocks_contrib/lti/lti.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@
8484
from xblockutils.resources import ResourceLoader
8585
from xblockutils.studio_editable import StudioEditableXBlockMixin
8686

87-
from .lti_2_util import LTI20BlockMixin, LTIError
88-
8987
from xblocks_contrib.common.xml_utils import LegacyXmlMixin
9088

89+
from .lti_2_util import LTI20BlockMixin, LTIError
90+
9191
# The anonymous user ID for the user in the course.
9292
ATTR_KEY_ANONYMOUS_USER_ID = 'edx-platform.anonymous_user_id'
9393
# The user's role in the course ('staff', 'instructor', or 'student').
@@ -1018,12 +1018,12 @@ def is_past_due(self):
10181018
return close_date is not None and datetime.datetime.now(UTC) > close_date
10191019

10201020
@classmethod
1021-
def definition_from_xml(cls, xml_object, system): # lint-amnesty, pylint: disable=unused-argument
1021+
def definition_from_xml(cls, xml_object, system):
10221022
if len(xml_object) == 0 and len(list(xml_object.items())) == 0:
10231023
return {'data': ''}, []
10241024
return {'data': etree.tostring(xml_object, pretty_print=True, encoding='unicode')}, []
10251025

1026-
def definition_to_xml(self, resource_fs): # lint-amnesty, pylint: disable=unused-argument
1026+
def definition_to_xml(self, resource_fs):
10271027
if self.data:
10281028
return etree.fromstring(self.data)
10291029
return etree.Element(self.category)

xblocks_contrib/poll/poll.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -304,20 +304,22 @@ def get_explicitly_set_fields_by_scope(self, scope=Scope.content):
304304
return result
305305

306306
@classmethod
307-
def definition_from_xml(cls, xml_object, system): # pylint: disable=unused-argument
308-
"""Pull out the data into dictionary.
307+
def definition_from_xml(cls, xml_object, system):
308+
"""
309+
Pull out the data into a dictionary.
309310
310311
Args:
311-
xml_object: xml from file.
312+
xml_object: XML from file.
312313
system: `system` object.
313314
314315
Returns:
315-
(definition, children) - tuple
316-
definition - dict:
317-
{
318-
'answers': <List of answers>,
319-
'question': <Question string>
320-
}
316+
tuple: A tuple ``(definition, children)``.
317+
318+
definition (dict):
319+
A dictionary containing:
320+
321+
- ``answers`` (list): List of answers.
322+
- ``question`` (str): Question string.
321323
"""
322324
# Check for presense of required tags in xml.
323325
if len(xml_object.xpath(cls._child_tag_name)) == 0:
@@ -338,7 +340,7 @@ def definition_from_xml(cls, xml_object, system): # pylint: disable=unused-argu
338340
children = []
339341
return (definition, children)
340342

341-
def definition_to_xml(self, resource_fs=None): # pylint: disable=unused-argument
343+
def definition_to_xml(self, resource_fs=None):
342344
"""Return an xml element representing to this definition."""
343345

344346
poll_str = HTML("<{tag_name}>{text}</{tag_name}>").format(tag_name=self._tag_name, text=self.question)

xblocks_contrib/word_cloud/word_cloud.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,12 @@ def index_dictionary(self):
313313
return xblock_body
314314

315315
@classmethod
316-
def definition_from_xml(cls, xml_object, system): # lint-amnesty, pylint: disable=unused-argument
316+
def definition_from_xml(cls, xml_object, system):
317317
if len(xml_object) == 0 and len(list(xml_object.items())) == 0:
318318
return {'data': ''}, []
319319
return {'data': etree.tostring(xml_object, pretty_print=True, encoding='unicode')}, []
320320

321-
def definition_to_xml(self, resource_fs): # lint-amnesty, pylint: disable=unused-argument
321+
def definition_to_xml(self, resource_fs):
322322
if self.data:
323323
return etree.fromstring(self.data)
324324
return etree.Element(self.category)

0 commit comments

Comments
 (0)