diff options
author | Benjamin Graham <benwilliamgraham@gmail.com> | 2020-02-04 12:09:43 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-04 18:09:43 +0100 |
commit | c49ff2a411ba6207116e2c7f5023d5247da460f0 (patch) | |
tree | 02d7a363ecd7a7ef14d1976fbe22e81c46f1d0e3 | |
parent | 09c94a2dce9e1eaec4d4e7ca81adb70d05970f5d (diff) | |
download | pylint-git-c49ff2a411ba6207116e2c7f5023d5247da460f0.tar.gz |
Fixed writing graphs to relative paths (#3378)
While playing around with the 'import-graph' setting, I noticed that attempting to write a graph to a local directory did not work as I would have expected.
For example, 'import-graph=docs/graph.dot' would attempt to add 'graph.dot' to '/LOCAL/PATH/docs/docs/'.
This was because the 'dot_sourcepath' in this scenario would be set to the combination of the 'storedir' ('/LOCAL/PATH/docs') and the 'outputfile' ('docs/graph.dot'). I am requesting that it be changed to just be 'outputfile' in this scenario.
Also, I have removed the instantiation of the 'dotfile' variable because it now has no use
Co-authored-by: Claudiu Popa <pcmanticore@gmail.com>
-rw-r--r-- | CONTRIBUTORS.txt | 3 | ||||
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | pylint/graph.py | 13 |
3 files changed, 7 insertions, 13 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index eb96651a5..0b82832b7 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -366,4 +366,7 @@ contributors: * Anubhav: contributor +* Ben Graham: contributor + * Anthony Tan: contributor + @@ -7,9 +7,7 @@ What's New in Pylint 2.5.0? Release date: TBA -* Remove unused import - - Close #3379 +* Fixed graph creation for relative paths * Add a check for asserts on string literals. diff --git a/pylint/graph.py b/pylint/graph.py index 0dc7a1460..9e0348144 100644 --- a/pylint/graph.py +++ b/pylint/graph.py @@ -71,30 +71,23 @@ class DotBackend: source = property(get_source) - def generate(self, outputfile=None, dotfile=None, mapfile=None): + def generate(self, outputfile=None, mapfile=None): """Generates a graph file. :param str outputfile: filename and path [defaults to graphname.png] - :param str dotfile: filename and path [defaults to graphname.dot] :param str mapfile: filename and path :rtype: str :return: a path to the generated file """ name = self.graphname - if not dotfile: - # if 'outputfile' is a dot file use it as 'dotfile' - if outputfile and outputfile.endswith(".dot"): - dotfile = outputfile - else: - dotfile = "%s.dot" % name if outputfile is not None: - storedir, _, target = target_info_from_filename(outputfile) + _, _, target = target_info_from_filename(outputfile) if target != "dot": pdot, dot_sourcepath = tempfile.mkstemp(".dot", name) os.close(pdot) else: - dot_sourcepath = osp.join(storedir, dotfile) + dot_sourcepath = outputfile else: target = "png" pdot, dot_sourcepath = tempfile.mkstemp(".dot", name) |