Do not access the file system for comparing filenames
Comparing the filenames as strings should be enough and makes tests
easier. normcase is called on the filenames for OSes with case
insensitive paths.
@@ -1079,10 +1079,10 @@ class Linter(metaclass=LinterMeta):
# the working directory
filename = os.path.normpath(os.path.join(self.get_working_dir(self.settings), filename))
+ # if this is a match for a different file we need its contents for
+ # the below checks
+ if os.path.normcase(filename) != os.path.normcase(self.filename):
try:
- # if this is a match for a different file we need its contents
- # for the below checks
- if not self.filename or not os.path.samefile(filename, self.filename):
vv = VirtualView.from_file(filename)
except OSError as err:
# warn about the error and drop this match
