Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Function 'logfile' assumes that filename is a string #430

Open
mborus opened this issue Dec 16, 2021 · 0 comments
Open

Function 'logfile' assumes that filename is a string #430

mborus opened this issue Dec 16, 2021 · 0 comments

Comments

@mborus
Copy link

mborus commented Dec 16, 2021

  • logzero version: 1.7.0
  • Python version: 3.9.9
  • Operating System: Windows 10

Description

in line 406 of 'init.,py' the function

def logfile(filename, ...

defines filename as a string (line 423)

  :arg string filename: Filename of the logfile. Set to `None` to disable logging to the logfile.

This causes problem with type checking, if you pass a Path (from python's pathlib), which is becoming more popular.

What I Did

Set a logfile using a pathlib Path

logzero.logfile(Path(LOGPATH, f"{mylog}.log"), maxBytes=1e6, backupCount=30)

I used PyCharm's "inspect code" feature and it flags this line as a type error.

Can you officially accept pathlib paths as a valid input so that type checking will work?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant