Use beautifulsoup4 CSS selectors to simplify code and type checking
As the types-beautifulsoup4 package gets installed in the swh virtualenv as it is a swh-scanner test dependency, some mypy errors were reported related to beautifulsoup4 typing. As the returned type for the find method of bs4 is the following union: Tag | NavigableString | None, isinstance calls must be used to ensure proper typing which is not great. So prefer to use the select_one method instead where a simple None check must be done to ensure typing is correct as it is returning Optional[Tag]. In a similar manner, replace use of find_all method by select method. It also has the advantage to simplify the code.
parent
e6a35c55
No related branches found
No related tags found
Showing
- requirements-test.txt 1 addition, 0 deletionsrequirements-test.txt
- swh/lister/arch/lister.py 23 additions, 21 deletionsswh/lister/arch/lister.py
- swh/lister/bioconductor/lister.py 5 additions, 4 deletionsswh/lister/bioconductor/lister.py
- swh/lister/cgit/lister.py 31 additions, 29 deletionsswh/lister/cgit/lister.py
- swh/lister/gitweb/lister.py 7 additions, 10 deletionsswh/lister/gitweb/lister.py
- swh/lister/maven/lister.py 12 additions, 22 deletionsswh/lister/maven/lister.py
- swh/lister/nuget/lister.py 1 addition, 1 deletionswh/lister/nuget/lister.py
- swh/lister/rubygems/lister.py 3 additions, 3 deletionsswh/lister/rubygems/lister.py
- swh/lister/sourceforge/lister.py 2 additions, 2 deletionsswh/lister/sourceforge/lister.py
- swh/lister/stagit/lister.py 17 additions, 10 deletionsswh/lister/stagit/lister.py
Please register or sign in to comment