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

Remove all instances of mutable objects (e.g. empty lists or dictionaries) as default parameter values #5169

Closed
dchristidis opened this issue Jan 20, 2022 · 2 comments
Assignees
Labels
Core & Internals enhancement Overview Used for overview issues, linking to other issues

Comments

@dchristidis
Copy link
Contributor

dchristidis commented Jan 20, 2022

Motivation

Read Python Mutable Defaults Are The Source of All Evil. The likelihood of this anti-pattern is low, but given the magnitude, it might be worth removing all such instances.

Modification

Identify all instances with pylint --disable=all --enable=W0102 lib/rucio/. Use None as default value, but add type hints and initialise the parameter in the body. For example:

def list_rules(filters={}, session=None):

Should become:

@stream_session
def list_rules(filters: Optional[Dict] = None, session: Session = None) -> Iterable[Dict]:
    …
    filters = filters or {}
    …
@bari12 bari12 added Core & Internals enhancement Overview Used for overview issues, linking to other issues labels Jan 20, 2022
@chinmaym07
Copy link

Hey Can I work on this ?

@bari12
Copy link
Member

bari12 commented Feb 24, 2022

Hi @chinmaym07 yes, please go ahead. I would suggest to go module by module, starting with the ones in https://github.com/rucio/rucio/tree/master/lib/rucio/core

erlingstaff added a commit to erlingstaff/rucio that referenced this issue Apr 18, 2024
erlingstaff added a commit to erlingstaff/rucio that referenced this issue Apr 18, 2024
erlingstaff added a commit to erlingstaff/rucio that referenced this issue Apr 22, 2024
erlingstaff added a commit to erlingstaff/rucio that referenced this issue Apr 23, 2024
erlingstaff added a commit to erlingstaff/rucio that referenced this issue Apr 23, 2024
erlingstaff added a commit to erlingstaff/rucio that referenced this issue Apr 23, 2024
erlingstaff added a commit to erlingstaff/rucio that referenced this issue Apr 24, 2024
erlingstaff added a commit to erlingstaff/rucio that referenced this issue Apr 24, 2024
erlingstaff added a commit to erlingstaff/rucio that referenced this issue Apr 24, 2024
erlingstaff added a commit to erlingstaff/rucio that referenced this issue Apr 26, 2024
erlingstaff added a commit to erlingstaff/rucio that referenced this issue Apr 26, 2024
erlingstaff added a commit to erlingstaff/rucio that referenced this issue Apr 26, 2024
@bari12 bari12 closed this as completed May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core & Internals enhancement Overview Used for overview issues, linking to other issues
Development

Successfully merging a pull request may close this issue.

4 participants