mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
linter: Add check that Optional models are tagged with null=True.
Exclude NullBooleanField explicitly. Amend one line in models.py found from this linter change.
This commit is contained in:
committed by
Tim Abbott
parent
7d93f5726c
commit
07971d3a66
@@ -494,6 +494,17 @@ def build_custom_checkers(by_lang):
|
||||
'bad_lines': ['desc = models.CharField(null=True) # type: Text',
|
||||
'stream = models.ForeignKey(Stream, null=True, on_delete=CASCADE) # type: Stream'],
|
||||
},
|
||||
{'pattern': ' = models[.](?!NullBoolean).*\) # type: Optional', # Optional tag, except NullBoolean(Field)
|
||||
'exclude_pattern': 'null=True',
|
||||
'include_only': {"zerver/models.py"},
|
||||
'description': 'Model variable annotated with Optional but variable does not have null=true.',
|
||||
'good_lines': ['desc = models.TextField(null=True) # type: Optional[Text]',
|
||||
'stream = models.ForeignKey(Stream, null=True, on_delete=CASCADE) # type: Optional[Stream]',
|
||||
'desc = models.TextField() # type: Text',
|
||||
'stream = models.ForeignKey(Stream, on_delete=CASCADE) # type: Stream'],
|
||||
'bad_lines': ['desc = models.TextField() # type: Optional[Text]',
|
||||
'stream = models.ForeignKey(Stream, on_delete=CASCADE) # type: Optional[Stream]'],
|
||||
},
|
||||
]) + whitespace_rules + comma_whitespace_rule
|
||||
bash_rules = cast(RuleList, [
|
||||
{'pattern': '#!.*sh [-xe]',
|
||||
|
||||
Reference in New Issue
Block a user