django icon indicating copy to clipboard operation
django copied to clipboard

Fixed #26472 -- Added silence_checks().

Open adamchainz opened this issue 2 years ago • 1 comments

ticket-26472

adamchainz avatar Jan 13 '22 18:01 adamchainz

Thanks for this!

This approach seems promising for granularly silencing checks related to fields but I'm curious how it would work for models, urls, and admin and other checks. We should at least have test coverage for that.

I think that's where the settings approach was shining in that it allowed for entries like ('urls.W002', 'some-pattern') or ('fields.E006', 'model.field') # this is a false positive in SILENCED_SYSTEM_CHECKS without Python gymnastics. Trying to support this pattern by relying on object identity instead of a documented object identifier (e.g. obj(Model) as opposed to Model._meta.label) will force us to ensure the definition/DSL object always makes its way to the check layer intact unless we ensure that objects passed to silence_check implement a check_identity method? I assume that ticket-33441 is one example of that?

In the end, I feel like system checks are very much a project thing and I fear that this approach might encourage third-party apps that ship code causing check violations to jump on this pattern instead of investigating and overriding methods such as Field.check. Is this something you had in mind?

charettes avatar Jan 13 '22 21:01 charettes