Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

immutables.Map() as default arg should not trigger B008 #133

Closed
hukkin opened this issue Aug 28, 2020 · 6 comments
Closed

immutables.Map() as default arg should not trigger B008 #133

hukkin opened this issue Aug 28, 2020 · 6 comments

Comments

@hukkin
Copy link

hukkin commented Aug 28, 2020

flake8-bugbear currently allows using the immutable frozenset() and tuple() types as default args of a function.

Would it be possible to also whitelist immutables.Map from https://github.com/MagicStack/immutables ?

@hukkin
Copy link
Author

hukkin commented Aug 28, 2020

To elaborate, would be great if the code below would not give me B008 error:

import immutables
from immutables import Map


def this_should_be_fine(mapping = immutables.Map()):
    pass

def this_also(mapping = Map()):
    pass

@cooperlees
Copy link
Collaborator

I'm going to pass this one to our core maintainer @ambv since this immutables.Map is from his MagicStack ...

I personally don't like us using not stdlib objects, but I'm open to this being an extra install maybe? If we find immytables.Map importable, don't fire the line?

@hukkin
Copy link
Author

hukkin commented Aug 28, 2020

I personally don't like us using not stdlib objects

Yeah I can see how this could be a bit of a bad precedent and a scope creep. Still would love having this one exception, as the stdlib does not include an immutable mapping/dict type, and using immutables types (tuple, frozenset, immutables.Map) as default arg makes me not have to write this convention a million times

def func(mapping = None):
    if mapping is None:
        mapping = {}

Thanks for considering!

@escaped
Copy link

escaped commented Jul 15, 2021

How about making the "immutable function calls" configurable via the ini files. Something like pep8-naming did for classmethod/staticmethod. It's not documented, but I can add exceptions to the config file like

[flake8]
# pep8-naming
classmethod-decorators =
  classmethod,  # buildin
  validator,  # pydantic
  root_validator,  # pydantic

@hukkin
Copy link
Author

hukkin commented Aug 26, 2021

I no longer have a need for this now that #144 is merged.

@hukkin
Copy link
Author

hukkin commented Jan 31, 2022

Closing this now that we have #204 and #144

@hukkin hukkin closed this as completed Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants