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
- Add
simplify-fastapi-query
check by @dosisod in #256 - Warn
datetime.{utcnow,utcfromtimestamp}
usages by @sobolevn in #259 - Do not run
isort
ontest/data
folder by @sobolevn in #264 - Add title and improve one fix by @ChaoticRoman in #265
- Improve coverage by @dosisod in #267
- Add
--verbose
flag, update documentation by @dosisod in #271 - Make
--verbose
output on a single line by @dosisod in #272 - Use
pip install -e .
inMakefile
by @sobolevn in #260
New Contributors
- @sobolevn made their first contribution in #259
- @ChaoticRoman made their first contribution in #265
Full Changelog: v1.17.0...v1.18.0