Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions addon/globalPlugins/clock/clockHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ def _getWaveFile(self, now, interval):
if target_minute == 0:
return os.path.join(paths.SOUNDS_DIR, config.conf["clockAndCalendar"]["timeReportSound"])
else:
return os.path.join(paths.SOUNDS_DIR, config.conf["clockAndCalendar"]["timeIntermediateReportSound"])
return os.path.join(
paths.SOUNDS_DIR,
config.conf["clockAndCalendar"]["timeIntermediateReportSound"],
)
return os.path.join(paths.SOUNDS_DIR, config.conf["clockAndCalendar"]["timeReportSound"])

def _getBoundaryTime(self, now, secs_to_boundary):
Expand Down Expand Up @@ -183,10 +186,14 @@ def _speakCurrentTime(self) -> None:
now = datetime.now()
ui.message(
safeGetTimeFormatEx(
None, None, now, formats.rgx.sub(
formats.repl, formats.timeFormats[config.conf['clockAndCalendar']['timeDisplayFormat']]
)
)
None,
None,
now,
formats.rgx.sub(
formats.repl,
formats.timeFormats[config.conf["clockAndCalendar"]["timeDisplayFormat"]],
),
),
)

def reportClock(self) -> None:
Expand Down
7 changes: 7 additions & 0 deletions addon/globalPlugins/clock/skipTranslation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
# Based on implementation made by Alberto Buffolino
# https://github.com/nvaccess/nvda/issues/4652

from typing import Callable

import addonHandler

addonHandler.initTranslation()
_: Callable[[str], str]


def translate(text):
return _(text)
3 changes: 3 additions & 0 deletions addon/installTasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
# Author: Hrvoje Katich and contributors
# Copyright 2013-2021, released under GPL.

from typing import Callable

import config
from configobj.validate import VdtTypeError
import addonHandler

addonHandler.initTranslation()
_: Callable[[str], str]


def onInstall():
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ logger-objects = ["logHandler.log"]
[tool.pyright]
venvPath = ".venv"
venv = "."
stubPath = ".vscode/typings"
pythonPlatform = "Windows"
typeCheckingMode = "strict"

Expand Down Expand Up @@ -146,7 +147,6 @@ reportInvalidStubStatement = true
reportInvalidTypeVarUse = true
reportMatchNotExhaustive = true
reportMissingModuleSource = true
reportMissingImports = true
reportNoOverloadImplementation = true
reportOptionalContextManager = true
reportOverlappingOverload = true
Expand All @@ -163,7 +163,6 @@ reportUnnecessaryCast = true
reportUnnecessaryContains = true
reportUnnecessaryTypeIgnoreComment = true
reportUntypedClassDecorator = true
reportUntypedFunctionDecorator = true
reportUnusedClass = true
reportUnusedCoroutine = true
reportUnusedExcept = true
Expand All @@ -173,6 +172,8 @@ reportDeprecated = false

# Can be enabled by generating type stubs for modules via pyright CLI
reportMissingTypeStubs = false
reportMissingImports = false
reportUntypedFunctionDecorator = false

# Bad rules
# These are roughly sorted by compliance to make it easier for devs to focus on enabling them.
Expand Down
13 changes: 7 additions & 6 deletions sconstruct
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def validateVersionNumber(key: str, val: str, _):


def expandGlobs(patterns: Iterable[str], rootdir: Path = Path(".")) -> list[FS.Entry]:
return [env.Entry(e) for pattern in patterns for e in rootdir.glob(pattern.lstrip('/'))]
return [env.Entry(e) for pattern in patterns for e in rootdir.glob(pattern.lstrip("/"))]


addonDir: Final = Path("addon/")
Expand All @@ -67,7 +67,7 @@ env.Append(
if env["dev"]:
from datetime import date

versionTimestamp = date.today().strftime('%Y%m%d')
versionTimestamp = date.today().strftime("%Y%m%d")
version = f"{versionTimestamp}.0.0"
env["addon_info"]["addon_version"] = version
env["versionNumber"] = version
Expand All @@ -84,7 +84,7 @@ env.Append(**env["addon_info"])
addonFile = env.File("${addon_name}-${addon_version}.nvda-addon")
addon = env.NVDAAddon(addonFile, env.Dir(addonDir), excludePatterns=buildVars.excludedFiles)

langDirs: list[FS.Dir] = [env.Dir(d) for d in env.Glob(localeDir/"*/") if d.isdir()]
langDirs: list[FS.Dir] = [env.Dir(d) for d in env.Glob(localeDir / "*/") if d.isdir()]

# Allow all NVDA's gettext po files to be compiled in source/locale, and manifest files to be generated
moByLang: dict[str, FS.File] = {}
Expand All @@ -95,7 +95,8 @@ for dir in langDirs:
moByLang[dir.name] = moFile
env.Depends(moTarget, poFile)
translatedManifest = env.NVDATranslatedManifest(
dir.File("manifest.ini"), [moFile, "manifest-translated.ini.tpl"]
dir.File("manifest.ini"),
[moFile, "manifest-translated.ini.tpl"],
)
env.Depends(translatedManifest, ["buildVars.py"])
env.Depends(addon, [translatedManifest, moTarget])
Expand All @@ -116,7 +117,7 @@ if (readmeFile := Path("readme.md")).is_file():
readmeTarget = env.Command(str(readmePath), str(readmeFile), Copy("$TARGET", "$SOURCE"))
env.Depends(addon, readmeTarget)

for mdFile in env.Glob(docsDir/"*/*.md"):
for mdFile in env.Glob(docsDir / "*/*.md"):
# the title of the html file is translated based on the contents of something in the moFile for a language.
# Thus, we find the moFile for this language and depend on it if it exists.
lang = mdFile.dir.name
Expand All @@ -143,7 +144,7 @@ env.Alias("mergePot", mergePot)
env.Depends(mergePot, i18nFiles)

# Generate Manifest path
manifest = env.NVDAManifest(env.File(addonDir/"manifest.ini"), "manifest.ini.tpl")
manifest = env.NVDAManifest(env.File(addonDir / "manifest.ini"), "manifest.ini.tpl")
# Ensure manifest is rebuilt if buildVars is updated.
env.Depends(manifest, "buildVars.py")

Expand Down
74 changes: 41 additions & 33 deletions site_scons/site_tools/NVDATool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ def generate(env: Environment):
env.SetDefault(excludePatterns=tuple())

addonAction = env.Action(
lambda target, source, env: createAddonBundleFromPath(
source[0].abspath,
target[0].abspath,
env["excludePatterns"],
)
and None,
lambda target, source, env: (
createAddonBundleFromPath(
source[0].abspath,
target[0].abspath,
env["excludePatterns"],
)
and None
),
lambda target, source, env: f"Generating Addon {target[0]}",
)
env["BUILDERS"]["NVDAAddon"] = Builder(
Expand All @@ -53,15 +55,17 @@ def generate(env: Environment):
env.SetDefault(speechDictionaries={})

manifestAction = env.Action(
lambda target, source, env: generateManifest(
source[0].abspath,
target[0].abspath,
addon_info=env["addon_info"],
brailleTables=env["brailleTables"],
symbolDictionaries=env["symbolDictionaries"],
speechDictionaries=env["speechDictionaries"],
)
and None,
lambda target, source, env: (
generateManifest(
source[0].abspath,
target[0].abspath,
addon_info=env["addon_info"],
brailleTables=env["brailleTables"],
symbolDictionaries=env["symbolDictionaries"],
speechDictionaries=env["speechDictionaries"],
)
and None
),
lambda target, source, env: f"Generating manifest {target[0]}",
)
env["BUILDERS"]["NVDAManifest"] = Builder(
Expand All @@ -71,16 +75,18 @@ def generate(env: Environment):
)

translatedManifestAction = env.Action(
lambda target, source, env: generateTranslatedManifest(
source[1].abspath,
target[0].abspath,
mo=source[0].abspath,
addon_info=env["addon_info"],
brailleTables=env["brailleTables"],
symbolDictionaries=env["symbolDictionaries"],
speechDictionaries=env["speechDictionaries"],
)
and None,
lambda target, source, env: (
generateTranslatedManifest(
source[1].abspath,
target[0].abspath,
mo=source[0].abspath,
addon_info=env["addon_info"],
brailleTables=env["brailleTables"],
symbolDictionaries=env["symbolDictionaries"],
speechDictionaries=env["speechDictionaries"],
)
and None
),
lambda target, source, env: f"Generating translated manifest {target[0]}",
)

Expand All @@ -93,14 +99,16 @@ def generate(env: Environment):
env.SetDefault(mdExtensions={})

mdAction = env.Action(
lambda target, source, env: md2html(
source[0].path,
target[0].path,
moFile=env["moFile"].path if env["moFile"] else None,
mdExtensions=env["mdExtensions"],
addon_info=env["addon_info"],
)
and None,
lambda target, source, env: (
md2html(
source[0].path,
target[0].path,
moFile=env["moFile"].path if env["moFile"] else None,
mdExtensions=env["mdExtensions"],
addon_info=env["addon_info"],
)
and None
),
lambda target, source, env: f"Generating {target[0]}",
)
env["BUILDERS"]["md2html"] = env.Builder(
Expand Down