-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Documentation Python scripts: fix pylint errors and warnings #9232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Documentation Python scripts: fix pylint errors and warnings #9232
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR modernizes two Python scripts in the Documentation directory to fix pylint warnings and errors. The changes focus on improving code quality by adopting modern Python best practices while maintaining the same functionality.
Key Changes:
- Replaced deprecated
codecsmodule with built-inopen()function for UTF-8 file handling - Added proper context managers (
withstatements) for file operations to ensure files are properly closed - Added docstrings to functions and modules for better code documentation
- Updated variable naming from camelCase to snake_case (e.g.,
citeDic→cite_dict,foundDouble→found_double) - Modernized string formatting by using f-strings and splitting long strings for better readability
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
Documentation/doc/scripts/pkglist_filter.py |
Modernized file handling with context managers, removed codecs import, added module and function docstrings, fixed indentation to 4 spaces, and improved variable naming |
Documentation/doc/scripts/generate_how_to_cite.py |
Removed codecs import, converted to context managers for file operations, renamed variables to snake_case, split long strings for line length compliance, updated one assertion to use f-string formatting, and reformatted multi-line strings |
Comments suppressed due to low confidence (2)
Documentation/doc/scripts/generate_how_to_cite.py:78
- Unnecessary string concatenation with += operator. The RESULT_TXT constant is split into two parts where the first part is a tuple concatenation (lines 20-26) and then line 27 adds more content with +=. This could be simplified by using a single multi-line string or by including all content in the initial tuple concatenation for better readability and consistency.
RESULT_TXT = (
r"""// This file was generated by generate_how_to_cite.py. """
r"""You shouldn't modify it directly.
/*!
\page how_to_cite_cgal Acknowledging %CGAL"""
)
RESULT_TXT += r"""
\details \cgal is implemented for the most part by researchers. The
academic world evaluates and rewards researchers for a good part by
the analysis of the number of published papers and the number of
citations of their papers, which measures their impact. In order to
make the \cgal project attractive for researchers to contribute their
work (which allows users to benefit from new contributions), we are
pushing a model where the \cgal manual chapters are considered like
publications, and can be cited in articles as such.
We therefore kindly ask users to cite \cgal as appropriately as
possible in their papers, and to mention the use of \cgal on the web
pages of their projects using \cgal and provide us with links to these
web pages. Feel free to contact us in case you have any question or
remark on this topic.
We provide bibtex entries for the chapters of the User and Reference
Manual, as well as for publications directly related to the \cgal
software.
## Citing the %CGAL Library or the %CGAL project ##
If you want to cite the \cgal Library or project as a whole, please
- cite: \cgal, Computational Geometry Algorithms Library, https://www.cgal.org
- use the first bibtex entry from the file <a href="how_to_cite_cgal.bib">how_to_cite_cgal.bib</a>.
## Citing the User and Reference Manual ##
If you want to refer to \cgal manual, please cite the appropriate
entry from the bibliographic entries for individual chapters listed
in the table below.
<table>
<tr valign="top">
<td align="right" class="bibtexnumber">
[<a name="cgal:eb-${CGAL_RELEASE_YEAR_ID}">1</a>]
</td>
<td class="bibtexitem">
The \cgal Project.
<em>\cgal User and Reference Manual</em>.
\cgal Editorial Board, ${CGAL_CREATED_VERSION_NUM} edition, ${CGAL_BUILD_YEAR4}.
</td><td width="75px">[ <a href="how_to_cite.html#cgal:eb-${CGAL_RELEASE_YEAR_ID}">bib</a> |
<a href="packages.html">http</a> ]
</td>
</tr>
"""
Documentation/doc/scripts/generate_how_to_cite.py:97
- Unnecessary string concatenation with += operator. The PRE_HTML constant is split into two parts where the first part is a tuple concatenation (lines 83-87) and then line 88 adds more content with +=. This could be simplified by using a single multi-line string or by including all content in the initial tuple concatenation for better readability and consistency.
PRE_HTML = (
r"""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" """
r""""https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">"""
)
PRE_HTML += r"""
<head>
<link rel="icon" type="image/png" href="../Manual/g-196x196-doc.png"/>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<link href="cgal_stylesheet.css" rel="stylesheet" type="text/css" />
<title>CGAL ${CGAL_CREATED_VERSION_NUM} - Manual: Acknowledging CGAL</title>
</head>
<body>
"""
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary of Changes
Modernize and fix
pylintwarnings and errors.Release Management