Closed astariul closed 2 years ago
I haven't tried it on Windows yet, since I'm using Linux on all of my machines.
Please set the environment variable
FLAKE518_DEBUG
to a value that can be transformed to True in Python.
The output should be more verbose than.
Thanks for the fast answer ! Here is my logs with FLAKE518_DEBUG="1"
:
Searching for 'pyproject.toml' in C:\Users\remon\Documents\workspace\pytere
Found C:\Users\remon\Documents\workspace\pytere\pyproject.toml
Reading C:\Users\remon\Documents\workspace\pytere\pyproject.toml
Found 'tool' section in C:\Users\remon\Documents\workspace\pytere\pyproject.toml
Searching for section 'flake8' in C:\Users\remon\Documents\workspace\pytere\pyproject.toml
Found section 'flake8' in C:\Users\remon\Documents\workspace\pytere\pyproject.toml
Searching for section 'flake518' in C:\Users\remon\Documents\workspace\pytere\pyproject.toml
Section 'flake518' does not exist in C:\Users\remon\Documents\workspace\pytere\pyproject.toml
Found entries in C:\Users\remon\Documents\workspace\pytere\pyproject.toml. Adding additional configuration...
The following configuration is written: {'flake8': {'max-line-length': 119, 'max-complexity': 10, 'per-file-ignores': '__init__.py:F401', 'extend-ignore': 'E203'}}
Using additional configuration file 'C:\Users\remon\Documents\workspace\pytere\.flake518_itzm8qeh.cfg' for flake8 call. File will be deleted afterwards
The following arguments are applied now: ['--config', 'C:\\Users\\remon\\Documents\\workspace\\pytere\\.flake518_itzm8qeh.cfg']
.\setup.py:8:80: E501 line too long (109 > 79 characters)
.\setup.py:9:80: E501 line too long (119 > 79 characters)
.\setup.py:10:80: E501 line too long (98 > 79 characters)
.\setup.py:17:80: E501 line too long (116 > 79 characters)
.\setup.py:18:80: E501 line too long (119 > 79 characters)
.\setup.py:19:80: E501 line too long (110 > 79 characters)
.\setup.py:22:80: E501 line too long (101 > 79 characters)
.\setup.py:35:80: E501 line too long (101 > 79 characters)
As you can see it's weird, the configuration is correctly detected ('max-line-length': 119
), but flake8 complains about too long lines...
Ok, can you add a '-vv' to your invocation to force flake8 to be more verbose.
Maybe it's an error or weird behavior of flake8.
Thanks for the detailed steps !
The output is huge though, and I don't really know where to look...
https://gist.github.com/astariul/190868d5410247d996f40960017f9119
When I invoke flake8
directly with the right options (flake8 --max-line-length 119
) it works fine.
Similarly, if I create a my_conf.cfg
file with the following content :
[flake8]
max-line-length = 119
and invoke it with flake8 --config .\my_conf.cfg
, it works fine (no warning displayed).
Thanks for the output. I think it might depend on the config file written by flame518. I'll set-up a more verbose revision of the tool that will not delete the config files so we can compare the output with a file created manually.
The output read was not really helpful and I doubt that there is a bug in flake8.
Which Python version are you using btw?
I'm using Python 3.7.11
With the OS env var FLAKE518_KEEPFILE=True in v1.2.1 you should be able to keep the file.
I'll keep using OS_ENV entries, until the successor of flake518 will be ready, which will have better configuration abilities.
Traceback (most recent call last):
File "C:\Users\remon\Miniconda3\envs\pytere\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\remon\Miniconda3\envs\pytere\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\remon\Miniconda3\envs\pytere\Scripts\flake518.exe\__main__.py", line 7, in <module>
File "C:\Users\remon\Miniconda3\envs\pytere\lib\site-packages\flake518\__main__.py", line 33, in main
run()
File "C:\Users\remon\Miniconda3\envs\pytere\lib\site-packages\flake518\adapter.py", line 234, in run
keep_file = _get_os_var_value("FLAKE518_KEEPFILE")
File "C:\Users\remon\Miniconda3\envs\pytere\lib\site-packages\flake518\adapter.py", line 70, in _get_os_var_value
return bool(flake518_dbg_env)
NameError: name 'flake518_dbg_env' is not defined
Seems like a typo in the latest release :) I'll open a quick PR to fix this. (See #11 )
After the fix, this is my file .flake518_5mshh5i3.cfg
:
[flake8]
max-line-length = 119
max-complexity = 10
per-file-ignores = __init__.py:F401
extend-ignore = E203
And when I run the command flake8 --config .flake518_5mshh5i3.cfg
, it works fine (no warning displayed).
I'm clueless what's going on... I think it's some permission on Windows that somehow needs to be set ? Everything else seems fine...
Commented on wrong issue ...
Ok, this is strange. I'll setup a windows machine with a demo project and I'll come back to you tomorrow.
@astariul I think there might be a chance to figure this out: could you please run flake8 --config C:\Users\remon\Documents\workspace\pytere\.flake518_5mshh5i3.cfg
- the chance is low, but there might be an issue with the full path passed over from the configuration file.
I tried and it worked fine (no warning displayed)...
For for your help !
Ok, this is really weird.
I'll come back to you with it tomorrow.
Can you also run flake8 --vv -config C:\Users\remon\Documents\workspace\pytere\.flake518_5mshh5i3.cfg
and compare it to the output in the gist? I might have a clue: The FS driver on Windows is sometimes rather slow, especially when using AV software in background. It might be the case, that the file cannot be read properly by flake8.
Diff between flake8 -vv
and flake8 -vv --config C:\Users\remon\Documents\workspace\pytere\.flake518_5mshh5i3.cfg
: https://www.diffchecker.com/SvPC5lXc
Difficult to read the diff...
After cleaning the diff a bit : https://www.diffchecker.com/rD0j7u9u
And here is the diff between flake8 -vv
and flake518 -vv
: https://www.diffchecker.com/eEFqd2OX
Oh hell yeah, this is yet about to become my favorite issue :(
censored swearing
Pardon my french.
The issue is gone, if I stop deleting the file. The file seems not to be visible to the file-system.
If I close the file after writing to it and check if it is exists, the result is False. If I set delete to False, it will be not removed but it will be shown as present.
So the issue is understood.
From Python's documentation:
This function operates exactly as TemporaryFile() does, except that the file is guaranteed to have a visible name in the file system (on Unix, the directory entry is not unlinked). ... Whether the name can be used to open the file a second time, while the named temporary file is still open, varies across platforms (it can be so used on Unix; it cannot on Windows NT or later). If delete is true (the default), the file is deleted as soon as it is closed.
According to this, I need wrap up creation and deletion according to a SystemExit exception.
I'll catch up with this later that week, if it is ok for you @astariul .
Thanks for investigation !
Mischief managed
Update coming in a few minutes
First of all, thanks for the great repo !
I tried it on Linux and it worked perfectly, but when I tried it on Windows, the configuration located in
pyproject.toml
is ignored silently...I couldn't figure the reason why.
Is there any specific configuration to do on Windows ?