N806 - false positive for class
Regarding N806 (variable in function should be lowercase) In Django I have a class that I create alias for which should be uppercase because it's still a class:
if a=1:
AliasMyClass = MyClass1
if a=2:
AliasMyClass = MyClass2
AliasMyClass.objects.create......
So it's clearly a false positive to me. Can you fix it?
We could consider changing the rule to allow a mixed-case variable name (left-hand side) if its being assigned to a mixed-case name (right-hand side).
@jparise I'm not confident in how necessary or common this is. It hasn't seen a lot of support or requests for help and I'm not certain relaxing this with no way to constrict it is the right choice.
@sigmavirus24 I think that's a fine position to take, too. I imagine these cases are rare in practice, so it's reasonable to ask users to annotate them with # noqa.
ModelName = apps.get_model("app_name.ModelName") and ModelNameFormSet = modelformset_factory(ModelName, ...) are perfectly sane patterns in Django projects. I'm not particularly familiar with AST inner workings, so I don't imagine it can be done thanks to Python's typing, but if a variable holds a type instance it shouldn't trigger N806.