<commit_before>import sublime
import sublime_plugin


class TabContextCommand(sublime_plugin.WindowCommand):
    def sheet(self, group, index):
        if group < 0 or index < 0:
            return None

        sheets = self.window.sheets_in_group(int(group))
        return sheets[index] if -1 < index < len(sheets) else None

    def view(self, group, index):
        return sheet.view() if (sheet := self.sheet(group, index)) else None

    def file_name(self, group, index):
        return view.file_name() if (view := self.view(group, index)) else None


class RevealTabInFinderCommand(TabContextCommand):
    def run(self, group=-1, index=-1):
        import os

        if path := self.file_name(group, index):
            dir, file = os.path.split(path)
            self.window.run_command("open_dir", {"dir": dir, "file": file})


class CopyTabFilePathCommand(TabContextCommand):
    def run(self, group=-1, index=-1):
        if path := self.file_name(group, index):<commit_msg>Add type hints for python plugins<commit_after>from typing import Optional

import sublime
import sublime_plugin


class TabContextCommand(sublime_plugin.WindowCommand):
    def sheet(self, group, index) -> Optional[sublime.View]:
        if group < 0 or index < 0:
            return None

        sheets = self.window.sheets_in_group(int(group))
        return sheets[index] if -1 < index < len(sheets) else None

    def view(self, group, index) -> Optional[sublime.View]:
        return sheet.view() if (sheet := self.sheet(group, index)) else None

    def file_name(self, group, index) -> Optional[str]:
        return view.file_name() if (view := self.view(group, index)) else None


class RevealTabInFinderCommand(TabContextCommand):
    def run(self, group=-1, index=-1):
        import os

        if path := self.file_name(group, index):
            dir, file = os.path.split(path)
            self.window.run_command("open_dir", {"dir": dir, "file": file})


class CopyTabFilePathCommand(TabContextCommand):
    def run(self, group=-1, index=-1):
        if path := self.file_name(group, index):
{'fraction_non_alphanumeric': 0.12213740458015267, 'fraction_numerical': 0.006679389312977099, 'mean_word_length': 3.194, 'pattern_counts': {'":': 4, '<': 11, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4361636', 'n_tokens_mistral': 648, 'n_tokens_neox': 626, 'n_words': 175}