Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor more speech functions #10593

Merged
merged 18 commits into from Jan 29, 2020
Merged

Refactor more speech functions #10593

merged 18 commits into from Jan 29, 2020

Conversation

feerrenrut
Copy link
Member

@feerrenrut feerrenrut commented Dec 8, 2019

Link to issue number:

None

Summary of the issue:

Returning sequences from these functions allows us greater flexibility for affecting all speech that is caused by a call to speakObject.

Description of how this pull request fixes the issue:

Split several functions into a speakX and getXspeech

This PR maintains backwards compatibility

Testing performed:

Ran NVDA from source.

Known issues with pull request:

  • Todo: rename getSpeechForSpelling to getSpellingSpeech

Change log entry:

Section: New features, Changes, Bug fixes

@feerrenrut feerrenrut requested a review from michaelDCurran Dec 8, 2019
@zstanecic

This comment has been minimized.

@michaelDCurran
Copy link
Member

michaelDCurran commented Dec 9, 2019

@Brian1Gaff

This comment has been minimized.

@feerrenrut
Copy link
Member Author

feerrenrut commented Dec 9, 2019

@zstanecic and @Brian1Gaff This PR does not break backwards compatibility. The description has been updated to make that clear.

@feerrenrut feerrenrut force-pushed the refactorMoreSpeechFunctions branch from 400554c to a48f1e4 Compare Dec 9, 2019
Copy link
Collaborator

@leonardder leonardder left a comment

This looks good to me, however note that I only had to had time to look at the code briefly, I haven't tested this. I therefore recommend a look from @michaelDCurran before merging this.

source/speech/__init__.py Outdated Show resolved Hide resolved
Copy link
Member

@michaelDCurran michaelDCurran left a comment

  • Would it be possible to make a new type annotation for 'reason'? All through this code you have reason: str. It would be great if this could be its own type.
  • with all the speakSelection functions: it would be good if they could take speech sequences, rather than just strings. Then speakSelectionChange can pass in a sequence from getTextInfoSpeech rather than just TextInfo.text. It also means that some of the code in speakSelectionChange can be replaced with a call to getSpellingSpeech. However, these changes would mean we can't have the text included with the message as part of one translatable string. Though I don't believe this is a bad thing.

source/speech/__init__.py Outdated Show resolved Hide resolved
source/speech/__init__.py Outdated Show resolved Hide resolved
@AppVeyorBot
Copy link

AppVeyorBot commented Dec 10, 2019

  • PR introduces Flake8 errors

See test results for failed build of commit 4ee5ba34ef

@feerrenrut feerrenrut force-pushed the refactorMoreSpeechFunctions branch from 29e56b8 to 193be74 Compare Dec 16, 2019
@feerrenrut feerrenrut force-pushed the refactorMoreSpeechFunctions branch from 5602078 to 582cb55 Compare Dec 27, 2019
@feerrenrut feerrenrut requested a review from michaelDCurran Jan 13, 2020
@michaelDCurran
Copy link
Member

michaelDCurran commented Jan 13, 2020

Is it just me, or have the changes to speech/__init__.py been lost in this pr?

@feerrenrut
Copy link
Member Author

feerrenrut commented Jan 14, 2020

Is it just me, or have the changes to speech/init.py been lost in this pr?

I think it's just you 😉. It is hidden from the diff initially because it is "large". You can jump to it, or other files by pressing 't' and typing __init__. A direct link to the file in the diff: https://github.com/nvaccess/nvda/pull/10593/files#diff-46301b9ce4a78abc208b3358db03e972

@feerrenrut feerrenrut added this to In progress in [Project] Speech Refactor via automation Jan 20, 2020
feerrenrut added 12 commits Jan 29, 2020
…Info

Clarify that the sequence is modified in place, nothing is spoken.
For now deprecate (but maintain) the old name.
For easier testing / refactoring.
Use instance methods directly.
Make speakWithoutPauses an instance method
- To make it more testable.
- Keep backwards compat; speakWithoutPauses name is added at module level.

Make getSpeechWithoutPauses a generator with return value.
- Speech can happen as it is generated, with the same number of calls
  to speak as previous implementation.
- Returns the same boolean values as previous implementation.
- To capture these return values, use GeneratorWithReturn class.

Add unit test for speechWithoutPauses
 - To ensure behavior has not changed between implementations
- Speech can happen as it is generated, with the same number of calls
  to speak as previous implementation.
- Returns the same boolean values as previous implementation.
- To capture these return values, use GeneratorWithReturn class.
feerrenrut added 6 commits Jan 29, 2020
Simplify the speakObject function by extracting this calculation into a
helper.
The new method '_objectSpeech_calculateAllowedProps()',
was extracted from 'speakObject()' and needs formatting
to pass linting checks.
Must flatten the results from getTextInfoSpeech generator.
Rename _speakPlaceholderIfEmpty -> _getPlaceholderSpeechIfTextEmpty
@feerrenrut
Copy link
Member Author

feerrenrut commented Jan 29, 2020

I'm going to rebase and merge this PR (to preserve the history of the refactor). I'll push after the rebase so that the commits in this PR / branch match.

@feerrenrut feerrenrut force-pushed the refactorMoreSpeechFunctions branch from 582cb55 to 9a884eb Compare Jan 29, 2020
feerrenrut added a commit that referenced this issue Jan 29, 2020
Split several functions into two. One speakX acts as before, but relies
on a new getXspeech which returns a speech sequence.

This PR maintains backwards compatibility.

This branch is being merged to preseve history of the refactor.
Merge remote-tracking branch 'origin/refactorMoreSpeechFunctions'
@feerrenrut feerrenrut merged commit 9a884eb into master Jan 29, 2020
1 check was pending
[Project] Speech Refactor automation moved this from In progress to Done Jan 29, 2020
@feerrenrut feerrenrut deleted the refactorMoreSpeechFunctions branch Jan 29, 2020
@nvaccessAuto nvaccessAuto added this to the 2019.3 milestone Jan 29, 2020
feerrenrut added a commit that referenced this issue Jan 29, 2020
@seanbudd seanbudd added the deprecated/2021.1 label Mar 5, 2021
seanbudd pushed a commit that referenced this issue Mar 22, 2021
Removes code provided for backwards compatibility in PR #10593

### Summary of the issue:

PR #10593 introduced `speech.speakWithoutPauses ` as an alias for `speech._speakWithoutPauses.speakWithoutPauses` and `speech.re_last_pause` as an alias for `speech._speakWithoutPauses.re_last_pause` for backwards compatibility. Since 2021.1 is going to be backwards compatibility breaking release it makes sense to remove these.

### Description of how this pull request fixes the issue:

These aliases are removed and their usages are replaces with `speech.SpeechWithoutPauses(speakFunc=speech.speak).speakWithoutPauses` and `speech.SpeechWithoutPauses.re_last_pause` respectively.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated/2021.1
Projects
Development

Successfully merging this pull request may close these issues.

None yet

8 participants