github dosisod/refurb v1.18.0
Version 1.18.0

latest releases: v2.0.0, v1.28.0, v1.27.0...
13 months ago

This release adds 4 new checks, a new flag, and a few bug fixes.

Add simplify-fastapi-query check (FURB175)

FastAPI will automatically pass along query parameters to your function, so you only need to use Query() when you use params other than default.

Bad:

@app.get("/")
def index(name: str = Query()) -> str:
    return f"Your name is {name}"

Good:

@app.get("/")
def index(name: str) -> str:
    return f"Your name is {name}"

Add unreliable-utc-usage check (FURB176)

Because naive datetime objects are treated by many datetime methods as local times, it is preferred to use aware datetimes to represent times in UTC.

This check affects datetime.utcnow and datetime.utcfromtimestamp.

Bad:

from datetime import datetime

now = datetime.utcnow()
past_date = datetime.utcfromtimestamp(some_timestamp)

Good:

from datetime import datetime, timezone

datetime.now(timezone.utc)
datetime.fromtimestamp(some_timestamp, tz=timezone.utc)

Add no-implicit-cwd check (FURB177)

If you want to get the current working directory don't call resolve() on an empty Path() object, use Path.cwd() instead.

Bad:

cwd = Path().resolve()

Good:

cwd = Path.cwd()

Add --verbose flag

This flag will spit out extra information about Refurb and related configuration info. Currently the --verbose flag will only print the enabled checks, though more information might be displayed in the future.


What's Changed

New Contributors

Full Changelog: v1.17.0...v1.18.0

Don't miss a new refurb release

NewReleases is sending notifications on new releases.