[SERVER-68924] Pylinters doesn't work out of the box on development workstations Created: 18/Aug/22  Updated: 29/Oct/23  Resolved: 04/Nov/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.2.0-rc0

Type: Bug Priority: Major - P3
Reporter: Kaloian Manassiev Assignee: Trevor Guidry
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

There are a couple of issues with pylinters.py which would make it a bit more friendly to the developer:

1. The error that buildscripts/pylinters.py lint-scons reports when it encounters something that needs to be fixed says:

ubuntu@kal-virtual-workstation:~/workspace/mongo$ buildscripts/pylinters.py lint-scons
adding module: enterprise
ERROR: Found diff for /home/ubuntu/workspace/mongo/src/mongo/db/SConscript
To fix formatting errors, run pylinters.py fix /home/ubuntu/workspace/mongo/src/mongo/db/SConscript
...

There are a couple with the instructions that are provided, first it needs to say buildscripts/pylinters.py (or at least to include the path from where pylinters.py was run) and second, if I run that command I get an error that absolute paths are not supported:

ubuntu@kal-virtual-workstation:~/workspace/mongo$ buildscripts/pylinters.py fix /home/ubuntu/workspace/mongo/src/mongo/db/SConscript
Traceback (most recent call last):
  File "/home/ubuntu/workspace/mongo/buildscripts/pylinters.py", line 273, in <module>
    main()
  File "/home/ubuntu/workspace/mongo/buildscripts/pylinters.py", line 269, in main
    args.func(args.linters, config_dict, args.file_names)
  File "/home/ubuntu/workspace/mongo/buildscripts/pylinters.py", line 191, in fix_func
    all_file_names = git.get_files_to_check(file_names, is_interesting_file)
  File "/home/ubuntu/workspace/mongo/buildscripts/linter/git.py", line 190, in get_files_to_check
    candidates_nested = [expand_file_string(f) for f in files]
  File "/home/ubuntu/workspace/mongo/buildscripts/linter/git.py", line 190, in <listcomp>
    candidates_nested = [expand_file_string(f) for f in files]
  File "/home/ubuntu/workspace/mongo/buildscripts/linter/git.py", line 151, in expand_file_string
    return [str(glob_match.resolve()) for glob_match in current_path.glob(glob_pattern)]
  File "/home/ubuntu/workspace/mongo/buildscripts/linter/git.py", line 151, in <listcomp>
    return [str(glob_match.resolve()) for glob_match in current_path.glob(glob_pattern)]
  File "/usr/local/lib/python3.9/pathlib.py", line 1165, in glob
    raise NotImplementedError("Non-relative patterns are unsupported")
NotImplementedError: Non-relative patterns are unsupported

2. When I run pylinters.py fix with the relative path, I get the following error:

ubuntu@kal-virtual-workstation:~/workspace/mongo$ buildscripts/pylinters.py fix src/mongo/db/SConscript
adding module: enterprise
Traceback (most recent call last):
  File "/home/ubuntu/workspace/mongo/buildscripts/pylinters.py", line 273, in <module>
    main()
  File "/home/ubuntu/workspace/mongo/buildscripts/pylinters.py", line 269, in main
    args.func(args.linters, config_dict, args.file_names)
  File "/home/ubuntu/workspace/mongo/buildscripts/pylinters.py", line 191, in fix_func
    all_file_names = git.get_files_to_check(file_names, is_interesting_file)
  File "/home/ubuntu/workspace/mongo/buildscripts/linter/git.py", line 199, in get_files_to_check
    raise ValueError("Globs '%s' did not find any files with glob in git." % (files))
ValueError: Globs '['src/mongo/db/SConscript']' did not find any files with glob in git.



 Comments   
Comment by Githook User [ 04/Nov/22 ]

Author:

{'name': 'Trevor Guidry', 'email': 'trevor.guidry@mongodb.com'}

Message: SERVER-68924 make pylinter output correct fix command and allow absolute paths
Branch: master
https://github.com/mongodb/mongo/commit/48a77e1d991933dcc182fe34e335a6d34bbddc55

Comment by Kevin Cherkauer [ 21/Sep/22 ]

Additional problem: in the error message "fix" should instead be "fix-scons".

Generated at Thu Feb 08 06:12:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.