Skip to content

Use with open instead of manually opening and closing file handler #53

@Tadaboody

Description

@Tadaboody

New smell

Smelly code

fp = open(path,args,kwargs)
# Body
fp.close

Fixed code

with open(path,args,kwargs as fp:
    # Body

Why is it smelly?

Without a context manager you need to manually close the file, which is eror-prone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    newThis issue hasn't been looked at yetsmellA new smell to report and fix

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions