wcmatch/glob.py
changed.
Other files ignored by Codecov
tox.ini
has changed.
618 | 618 | try: |
|
619 | 619 | fd = None # type: Optional[int] |
|
620 | 620 | if self.is_abs_pattern and curdir: |
|
621 | - | scandir = curdir # type: Union[AnyStr, int] |
|
621 | + | scandir = curdir # type: AnyStr |
|
622 | 622 | elif self.dir_fd is not None: |
|
623 | - | fd = scandir = os.open( |
|
623 | + | fd = os.open( |
|
624 | 624 | os.path.join(self.root_dir, curdir) if curdir else self.root_dir, |
|
625 | 625 | _wcmatch.DIR_FLAGS, |
|
626 | 626 | dir_fd=self.dir_fd |
633 | 633 | yield special, True, True, False |
|
634 | 634 | ||
635 | 635 | try: |
|
636 | - | with os.scandir(scandir) as scan: # type: ignore[type-var] |
|
637 | - | for f in scan: |
|
638 | - | try: |
|
639 | - | hidden = self._is_hidden(f.name) # type: ignore[arg-type] |
|
640 | - | is_dir = f.is_dir() |
|
641 | - | if is_dir: |
|
642 | - | is_link = f.is_symlink() |
|
643 | - | else: |
|
644 | - | # We don't care if a file is a link |
|
645 | - | is_link = False |
|
646 | - | if (not dir_only or is_dir): |
|
647 | - | yield f.name, is_dir, hidden, is_link # type: ignore[misc] |
|
648 | - | except OSError: # pragma: no cover |
|
649 | - | pass |
|
636 | + | if sys.version_info > (3, 6): |
|
637 | + | with os.scandir(cast(Union[AnyStr, int], fd if fd is not None else scandir)) as scan: |
|
638 | + | for f in scan: |
|
639 | + | try: |
|
640 | + | hidden = self._is_hidden(f.name) # type: ignore[arg-type] |
|
641 | + | is_dir = f.is_dir() |
|
642 | + | if is_dir: |
|
643 | + | is_link = f.is_symlink() |
|
644 | + | else: |
|
645 | + | # We don't care if a file is a link |
|
646 | + | is_link = False |
|
647 | + | if (not dir_only or is_dir): |
|
648 | + | yield f.name, is_dir, hidden, is_link # type: ignore[misc] |
|
649 | + | except OSError: # pragma: no cover |
|
650 | + | pass |
|
651 | + | else: |
|
652 | + | with os.scandir(scandir) as scan: |
|
653 | + | for f in scan: |
|
654 | + | try: |
|
655 | + | hidden = self._is_hidden(f.name) |
|
656 | + | is_dir = f.is_dir() |
|
657 | + | if is_dir: |
|
658 | + | is_link = f.is_symlink() |
|
659 | + | else: |
|
660 | + | # We don't care if a file is a link |
|
661 | + | is_link = False |
|
662 | + | if (not dir_only or is_dir): |
|
663 | + | yield f.name, is_dir, hidden, is_link |
|
664 | + | except OSError: # pragma: no cover |
|
665 | + | pass |
|
650 | 666 | finally: |
|
651 | 667 | if fd is not None: |
|
652 | 668 | os.close(fd) |
Files | Coverage |
---|---|
wcmatch | 99.53% |
Project Totals (10 files) | 99.53% |