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

Added checks for except* clause to report invalid usage that is fla… #9419

Merged
merged 1 commit into from
Nov 7, 2024
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
6 changes: 5 additions & 1 deletion packages/pyright-internal/src/localization/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ export namespace Localizer {
new ParameterizedString<{ type: string; methodName: string; paramName: string }>(
getRawString('Diagnostic.bindTypeMismatch')
);
export const breakInExceptionGroup = () => getRawString('Diagnostic.breakInExceptionGroup');
export const breakOutsideLoop = () => getRawString('Diagnostic.breakOutsideLoop');
export const callableExtraArgs = () => getRawString('Diagnostic.callableExtraArgs');
export const callableFirstArg = () => getRawString('Diagnostic.callableFirstArg');
Expand Down Expand Up @@ -356,7 +357,7 @@ export namespace Localizer {
new ParameterizedString<{ leftType: string; rightType: string }>(
getRawString('Diagnostic.containmentAlwaysTrue')
);
export const continueInFinally = () => getRawString('Diagnostic.continueInFinally');
export const continueInExceptionGroup = () => getRawString('Diagnostic.continueInExceptionGroup');
export const continueOutsideLoop = () => getRawString('Diagnostic.continueOutsideLoop');
export const dataClassBaseClassFrozen = () => getRawString('Diagnostic.dataClassBaseClassFrozen');
export const dataClassBaseClassNotFrozen = () => getRawString('Diagnostic.dataClassBaseClassNotFrozen');
Expand Down Expand Up @@ -455,6 +456,8 @@ export namespace Localizer {
new ParameterizedString<{ name: string }>(getRawString('Diagnostic.enumMemberSet'));
export const enumMemberTypeAnnotation = () => getRawString('Diagnostic.enumMemberTypeAnnotation');
export const exceptionGroupIncompatible = () => getRawString('Diagnostic.exceptionGroupIncompatible');
export const exceptGroupMismatch = () => getRawString('Diagnostic.exceptGroupMismatch');
export const exceptGroupRequiresType = () => getRawString('Diagnostic.exceptGroupRequiresType');
export const exceptionGroupTypeIncorrect = () => getRawString('Diagnostic.exceptionGroupTypeIncorrect');
export const exceptionTypeIncorrect = () =>
new ParameterizedString<{ type: string }>(getRawString('Diagnostic.exceptionTypeIncorrect'));
Expand Down Expand Up @@ -866,6 +869,7 @@ export namespace Localizer {
export const returnInAsyncGenerator = () => getRawString('Diagnostic.returnInAsyncGenerator');
export const returnMissing = () =>
new ParameterizedString<{ returnType: string }>(getRawString('Diagnostic.returnMissing'));
export const returnInExceptionGroup = () => getRawString('Diagnostic.returnInExceptionGroup');
export const returnOutsideFunction = () => getRawString('Diagnostic.returnOutsideFunction');
export const returnTypeContravariant = () => getRawString('Diagnostic.returnTypeContravariant');
export const returnTypeMismatch = () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
"constructorParametersMismatch": "Neshoda mezi signaturou __new__ a __init__ ve třídě“ {classType}“",
"containmentAlwaysFalse": "Výraz se vždy vyhodnotí jako False, protože typy „{leftType}“ a „{rightType}“ se nepřekrývají",
"containmentAlwaysTrue": "Výraz se vždy vyhodnotí jako True, protože typy „{leftType}“ a „{rightType}“ se nepřekrývají.",
"continueInFinally": "continue není možné použít v klauzuli finally",
"continueOutsideLoop": "continue se dá použít jenom ve smyčce",
"coroutineInConditionalExpression": "Podmíněný výraz odkazuje na korutinu, která se vždy vyhodnotí jako True.",
"dataClassBaseClassFrozen": "Nezablokovaná třída nemůže dědit z zmrazené třídy",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
"constructorParametersMismatch": "Keine Übereinstimmung zwischen der Signatur von __new__ und __init__ in der Klasse \"{classType}\"",
"containmentAlwaysFalse": "Der Ausdruck wird immer als False ausgewertet, da die Typen \"{leftType}\" und \"{rightType}\" keine Überlappung aufweisen.",
"containmentAlwaysTrue": "Der Ausdruck wird immer als True ausgewertet, da die Typen \"{leftType}\" und \"{rightType}\" keine Überlappung aufweisen.",
"continueInFinally": "\"continue\" kann nicht innerhalb einer finally-Klausel verwendet werden.",
"continueOutsideLoop": "\"continue\" kann nur innerhalb einer Schleife verwendet werden.",
"coroutineInConditionalExpression": "Bedingter Ausdruck verweist auf eine Coroutine, die immer zu \"True\" ausgewertet wird.",
"dataClassBaseClassFrozen": "Eine nicht fixierte Klasse kann nicht von einer fixierten Klasse erben.",
Expand Down
22 changes: 19 additions & 3 deletions packages/pyright-internal/src/localization/package.nls.en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@
"message": "Could not bind method \"{methodName}\" because \"{type}\" is not assignable to parameter \"{paramName}\"",
"comment": "Binding is the process through which Pyright determines what object a name refers to"
},
"breakInExceptionGroup": {
"message": "\"break\" is not allowed in an \"except*\" block",
"comment": "{Locked='break','except*'}"
},
"breakOutsideLoop": {
"message": "\"break\" can be used only within a loop",
"comment": "{Locked='break'}"
Expand Down Expand Up @@ -201,9 +205,9 @@
"message": "Expression will always evaluate to True since the types \"{leftType}\" and \"{rightType}\" have no overlap",
"comment": "{Locked='True'}"
},
"continueInFinally": {
"message": "\"continue\" cannot be used within a finally clause",
"comment": "{Locked='continue','finally'}"
"continueInExceptionGroup": {
"message": "\"continue\" is not allowed in an \"except*\" block",
"comment": "{Locked='continue','except*'}"
},
"continueOutsideLoop": {
"message": "\"continue\" can be used only within a loop",
Expand Down Expand Up @@ -341,6 +345,14 @@
"message": "Exception group syntax (\"except*\") requires Python 3.11 or newer",
"comment": "{Locked='except*'}"
},
"exceptGroupMismatch": {
"message": "Try statement cannot include both \"except\" and \"except*\"",
"comment": "{Locked='except','except*'}"
},
"exceptGroupRequiresType": {
"message": "Exception group syntax (\"except*\") requires an exception type",
"comment": "{Locked='except*'}"
},
"exceptionGroupTypeIncorrect": {
"message": "Exception type in except* cannot derive from BaseGroupException",
"comment": "{Locked='except*','BaseGroupException'}"
Expand Down Expand Up @@ -1084,6 +1096,10 @@
"comment": "{Locked='async'}"
},
"returnMissing": "Function with declared return type \"{returnType}\" must return value on all code paths",
"returnInExceptionGroup": {
"message": "\"return\" is not allowed in an \"except*\" block",
"comment": "{Locked='return','except*'}"
},
"returnOutsideFunction": {
"message": "\"return\" can be used only within a function",
"comment": "{Locked='return'}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
"constructorParametersMismatch": "Error de coincidencia entre la firma de __new__ y __init__ en la clase \"{classType}\"",
"containmentAlwaysFalse": "La expresión siempre se evaluará como False, ya que los tipos \"{leftType}\" y \"{rightType}\" no tienen superposición",
"containmentAlwaysTrue": "La expresión siempre se evaluará como True, ya que los tipos \"{leftType}\" y \"{rightType}\" no tienen superposición",
"continueInFinally": "\"continue\" no puede utilizarse dentro de una cláusula finally",
"continueOutsideLoop": "\"continue\" solo puede utilizarse dentro de un bucle",
"coroutineInConditionalExpression": "La expresión condicional hace referencia a una corrutina que siempre se evalúa como True",
"dataClassBaseClassFrozen": "Una clase no inmovilizada no puede heredar de una clase inmovilizada",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
"constructorParametersMismatch": "Non-concordance entre la signature de __new__ et __init__ dans la classe \"{classType}\"",
"containmentAlwaysFalse": "L'expression sera toujours évaluée à False car les types \"{leftType}\" et \"{rightType}\" ne se chevauchent pas",
"containmentAlwaysTrue": "L'expression sera toujours évaluée à True puisque les types \"{leftType}\" et \"{rightType}\" ne se chevauchent pas",
"continueInFinally": "« continuer » ne peut pas être utilisé dans une clause finally",
"continueOutsideLoop": "« continuer » ne peut être utilisé qu’au sein d’une boucle",
"coroutineInConditionalExpression": "L'expression conditionnelle fait référence à une coroutine qui est toujours évaluée à True",
"dataClassBaseClassFrozen": "Une classe non gelée ne peut pas hériter d'une classe gelée",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
"constructorParametersMismatch": "Mancata corrispondenza tra firma di __new__ e __init__ nella classe \"{classType}\"",
"containmentAlwaysFalse": "L'espressione restituisce sempre False perché i tipi \"{leftType}\" e \"{rightType}\" non si sovrappongono",
"containmentAlwaysTrue": "L'espressione restituisce sempre True perché i tipi \"{leftType}\" e \"{rightType}\" non si sovrappongono",
"continueInFinally": "Non è possibile usare \"continue\" all'interno di una clausola finally",
"continueOutsideLoop": "\"continue\" può essere usato solo all'interno di un ciclo",
"coroutineInConditionalExpression": "L'espressione condizionale fa riferimento a una coroutine che restituisce sempre True",
"dataClassBaseClassFrozen": "Una classe non bloccata non può ereditare da una classe bloccata",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
"constructorParametersMismatch": "クラス \"{classType}\" の__new__と__init__のシグネチャの不一致",
"containmentAlwaysFalse": "型 \"{leftType}\" と \"{rightType}\" に重複がないため、式は常に False に評価されます",
"containmentAlwaysTrue": "型 \"{leftType}\" と \"{rightType}\" に重複がないため、式は常に True に評価されます",
"continueInFinally": "finally 句内では \"continue\" を使用できません",
"continueOutsideLoop": "\"continue\" はループ内でのみ使用できます",
"coroutineInConditionalExpression": "常に True に評価される条件式参照コルーチン",
"dataClassBaseClassFrozen": "固定されていないクラスは、固定されているクラスから継承できません",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
"constructorParametersMismatch": "‘{classType}’ 클래스에서 __new__ 서명과 __init__가 불일치합니다.",
"containmentAlwaysFalse": "‘{leftType}’ 및 ‘{rightType}’ 형식이 겹치지 않으므로 식은 항상 False로 평가됩니다.",
"containmentAlwaysTrue": "‘{leftType}’ 및 ‘{rightType}’ 형식이 겹치지 않으므로 식은 항상 True로 평가됩니다.",
"continueInFinally": "finally 절 내에서는 \"continue\"를 사용할 수 없습니다.",
"continueOutsideLoop": "\"continue\"는 루프 내에서만 사용할 수 있습니다.",
"coroutineInConditionalExpression": "조건식은 항상 True로 평가되는 코루틴을 참조합니다.",
"dataClassBaseClassFrozen": "고정되지 않은 클래스는 고정된 클래스에서 상속할 수 없습니다.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
"constructorParametersMismatch": "Niezgodność między sygnaturą „__new__” i „__init__” w klasie „{classType}”",
"containmentAlwaysFalse": "Warunek zawsze będzie miał wartość False, ponieważ typy „{leftType}” i „{rightType}” nie nakładają się na siebie",
"containmentAlwaysTrue": "Warunek zawsze będzie miał wartość „True”, ponieważ typy „{leftType}” i „{rightType}” nie nakładają się na siebie",
"continueInFinally": "Wartość „continue” nie może być używana w klauzuli finally",
"continueOutsideLoop": "Wartość „continue” może być używana tylko w pętli",
"coroutineInConditionalExpression": "Wyrażenie warunkowe odwołuje się do koprocedury, która zawsze wyznacza wartość True",
"dataClassBaseClassFrozen": "Klasa niezablokowana nie może dziedziczyć po klasie zablokowanej",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
"constructorParametersMismatch": "Incompatibilidade entre a assinatura de __new__ e __init__ na classe \"{classType}\"",
"containmentAlwaysFalse": "A expressão sempre será avaliada como False, pois os tipos \"{leftType}\" e \"{rightType}\" não têm sobreposição",
"containmentAlwaysTrue": "A expressão sempre será avaliada como True, pois os tipos \"{leftType}\" e \"{rightType}\" não têm sobreposição",
"continueInFinally": "\"continue\" não pode ser usado em uma cláusula finally",
"continueOutsideLoop": "\"continue\" só pode ser usado dentro de um loop",
"coroutineInConditionalExpression": "A expressão condicional faz referência à corrotina, que sempre é avaliada como True",
"dataClassBaseClassFrozen": "Uma classe não congelada não pode herdar de uma classe congelada",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
"constructorParametersMismatch": "[WWloK][นั้Mïsmætçh þëtwëëñ sïgñætµrë øf __new__ æñð __init__ ïñ çlæss \"{çlæssTÿpë}\"Ấğ倪İЂҰक्र्तिृまẤğ倪İЂҰक्र्तिृまẤนั้ढूँ]",
"containmentAlwaysFalse": "[e6PIv][นั้Ëxprëssïøñ wïll ælwæÿs ëvælµætë tø False sïñçë thë tÿpës \"{lëftTÿpë}\" æñð \"{rïghtTÿpë}\" hævë ñø øvërlæpẤğ倪İЂҰक्र्तिृまẤğ倪İЂҰक्र्तिृまẤğ倪İЂҰक्र्तिृนั้ढूँ]",
"containmentAlwaysTrue": "[8OhUO][นั้Ëxprëssïøñ wïll ælwæÿs ëvælµætë tø True sïñçë thë tÿpës \"{lëftTÿpë}\" æñð \"{rïghtTÿpë}\" hævë ñø øvërlæpẤğ倪İЂҰक्र्तिृまẤğ倪İЂҰक्र्तिृまẤğ倪İЂҰक्र्तिृนั้ढूँ]",
"continueInFinally": "[RZIyI][นั้\"continue\" çæññøt þë µsëð wïthïñ æ finally çlæµsëẤğ倪İЂҰक्र्तिृまẤğ倪İЂҰนั้ढूँ]",
"continueOutsideLoop": "[6ACvd][นั้\"continue\" çæñ þë µsëð øñlÿ wïthïñ æ løøpẤğ倪İЂҰक्र्तिृまẤğนั้ढूँ]",
"coroutineInConditionalExpression": "[ygK2r][นั้Çøñðïtïøñæl ëxprëssïøñ rëfërëñçës çørøµtïñë whïçh ælwæÿs ëvælµætës tø TrueẤğ倪İЂҰक्र्तिृまẤğ倪İЂҰक्र्तिृまẤğนั้ढूँ]",
"dataClassBaseClassFrozen": "[jjiw4][นั้Æ ñøñ-frøzëñ çlæss çæññøt ïñhërït frøm æ çlæss thæt ïs frøzëñẤğ倪İЂҰक्र्तिृまẤğ倪İЂҰक्र्นั้ढूँ]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
"constructorParametersMismatch": "Несоответствие подписи __new__ и __init__ в классе \"{classType}\"",
"containmentAlwaysFalse": "Выражение всегда будет оцениваться как False, так как типы \"{leftType}\" и \"{rightType}\" не перекрываются",
"containmentAlwaysTrue": "Выражение всегда будет оцениваться как True, так как типы \"{leftType}\" и \"{rightType}\" не перекрываются",
"continueInFinally": "Невозможно использовать \"continue\" в предложении finally",
"continueOutsideLoop": "Ключевое слово \"continue\" можно использовать только внутри цикла",
"coroutineInConditionalExpression": "Условное выражение ссылается на сопрограмму, которая всегда возвращает значение True",
"dataClassBaseClassFrozen": "Незафиксированный класс не может наследоваться от зафиксированного класса",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
"constructorParametersMismatch": "\"{classType}\" sınıfındaki __new__ ve __init__ imzaları arasında uyuşmazlık var",
"containmentAlwaysFalse": "\"{leftType}\" türleri ve \"{rightType}\" türleri çakışmadığından ifade her zaman False olarak değerlendirilir",
"containmentAlwaysTrue": "\"{leftType}\" türleri ve \"{rightType}\" türleri çakışmadığından ifade her zaman True olarak değerlendirilir",
"continueInFinally": "\"continue\" finally yan tümcesi içinde kullanılamaz",
"continueOutsideLoop": "\"continue\" yalnızca bir döngü içinde kullanılabilir",
"coroutineInConditionalExpression": "Koşullu ifade, her zaman True olarak değerlendirilen eş yordama başvurur",
"dataClassBaseClassFrozen": "Dondurulmuş olmayan bir sınıf dondurulmuş bir sınıftan devralamaz",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
"constructorParametersMismatch": "类“{classType}”中__new__和__init__的签名不匹配",
"containmentAlwaysFalse": "表达式的计算结果始终为 False,因为类型“{leftType}”和“{rightType}”没有重叠",
"containmentAlwaysTrue": "表达式的计算结果始终为 True,因为类型“{leftType}”和“{rightType}”没有重叠",
"continueInFinally": "“continue”不能在 finally 子句中使用",
"continueOutsideLoop": "“continue”只能在循环中使用",
"coroutineInConditionalExpression": "始终计算结果为 True 的条件表达式引用协同例程",
"dataClassBaseClassFrozen": "非冻结类不能从已冻结类继承",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
"constructorParametersMismatch": "類別 \"{classType}\" 中__new__與__init__的簽章不相符",
"containmentAlwaysFalse": "運算式一律會評估為 False,因為型別 \"{leftType}\" 和 \"{rightType}\" 沒有重疊",
"containmentAlwaysTrue": "運算式一律會評估為 True,因為型別 \"{leftType}\" 和 \"{rightType}\" 沒有重疊",
"continueInFinally": "\"continue\" 不能在 finally 子句內使用",
"continueOutsideLoop": "\"continue\" 只能在 loop 內使用",
"coroutineInConditionalExpression": "條件運算式參考協同程式,一律評估為 True",
"dataClassBaseClassFrozen": "未凍結的類別無法繼承已凍結的類別",
Expand Down
Loading
Loading