Skip to content

Commit

Permalink
ref: match base class signature of render(...) for widgets (#74896)
Browse files Browse the repository at this point in the history
<!-- Describe your PR here. -->
  • Loading branch information
asottile-sentry authored Jul 25, 2024
1 parent 3411112 commit 9518f62
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/sentry/web/forms/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ def validate(self, value):

class UserField(CharField):
class widget(TextInput):
def render(self, name, value, attrs=None):
def render(self, name, value, attrs=None, renderer=None):
if not attrs:
attrs = {}
if "placeholder" not in attrs:
attrs["placeholder"] = "username"
attrs.setdefault("placeholder", "username")
if isinstance(value, int):
value = User.objects.get(id=value).username
return super().render(name, value, attrs)
return super().render(name, value, attrs=attrs, renderer=renderer)

def clean(self, value):
value = super().clean(value)
Expand All @@ -50,7 +49,7 @@ def clean(self, value):


class ReadOnlyTextWidget(Widget):
def render(self, name, value, attrs):
def render(self, name, value, attrs=None, renderer=None):
final_attrs = self.build_attrs(attrs)
if not value:
value = mark_safe("<em>%s</em>" % _("Not set"))
Expand Down

0 comments on commit 9518f62

Please sign in to comment.