Skip to content

Commit

Permalink
dummy vars renamed __x__ for compatibility with pyright
Browse files Browse the repository at this point in the history
  • Loading branch information
phelps-sg committed Nov 5, 2023
1 parent 6c22873 commit 5e261d4
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ callbacks=cb_,

# A regular expression matching the name of dummy variables (i.e. expected/var to
# not be used).
dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_
dummy-variables-rgx=_+$|(__[a-zA-Z0-9_]*[a-zA-Z0-9]+__$)|dummy|^ignored_|^unused_

# Argument names that match this expression will be ignored.
ignored-argument-names=_.*|^ignored_|^unused_
Expand All @@ -636,4 +636,4 @@ init-import=no
redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io

[MASTER]
disable=C0114,C0116,C0115,R0902,R0913,R1735,R0903,C0103,R1705,W0621
disable=C0114,C0116,C0115,R0902,R0913,R1735,R0903,C0103,R1705,W0621,R0801
8 changes: 4 additions & 4 deletions llm_cooperation/experiments/dilemma.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,22 @@ def round_instructions() -> str:

# pylint: disable=unused-argument
def strategy_defect(
state: GameState[DilemmaChoice, ChainOfThoughtCondition, str], **_kwargs: bool
state: GameState[DilemmaChoice, ChainOfThoughtCondition, str], **__kwargs__: bool
) -> DilemmaChoice:
return Defect


# pylint: disable=unused-argument
def strategy_cooperate(
state: GameState[DilemmaChoice, ChainOfThoughtCondition, str], **_kwargs: bool
state: GameState[DilemmaChoice, ChainOfThoughtCondition, str], **__kwargs__: bool
) -> DilemmaChoice:
return Cooperate


def strategy_t4t(
initial_choice: DilemmaChoice,
state: GameState[DilemmaChoice, ChainOfThoughtCondition, str],
**_kwargs: bool,
**__kwargs__: bool,
) -> DilemmaChoice:
if len(state.messages) == 2:
return initial_choice
Expand Down Expand Up @@ -152,7 +152,7 @@ def choice_from_str(choice: str) -> DilemmaChoice:
raise ValueError(f"Cannot determine choice from {choice}")


def extract_choice_pd(completion: Completion, **_kwargs: bool) -> DilemmaChoice:
def extract_choice_pd(completion: Completion, **__kwargs__: bool) -> DilemmaChoice:
regex: str = r".*project (blue|green)"
choice_regex: str = f"choice:{regex}"
logger.debug("completion = %s", completion)
Expand Down
4 changes: 2 additions & 2 deletions llm_cooperation/experiments/principalagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ def extract_choice_pa(completion: Completion) -> PAChoice:
raise ValueError(f"Cannot determine choice from {completion}")


def payoffs_pa(_choice: PAChoice) -> float:
def payoffs_pa(__choice__: PAChoice) -> float:
return np.nan


def compute_freq_pa(_choice: PAChoice) -> float:
def compute_freq_pa(__choice__: PAChoice) -> float:
return np.nan


Expand Down
2 changes: 1 addition & 1 deletion llm_cooperation/gametypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import List, Protocol, Tuple

from openai_pygenerator import Completer, Completion, History, user_message
from openai_pygenerator import Completer, Completion, user_message

from llm_cooperation import PT, RT, ModelSetup, PT_contra, RT_contra, completer_for

Expand Down
2 changes: 1 addition & 1 deletion llm_cooperation/gametypes/oneshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def generate_samples(
participant_condition: PT,
) -> Iterable[Tuple[float, float, Optional[CT], List[str]]]:
# pylint: disable=R0801
for _i in range(num_samples):
for __i__ in range(num_samples):
conversation = play_game(
role_prompt=prompt,
participant_condition=participant_condition,
Expand Down
2 changes: 1 addition & 1 deletion llm_cooperation/gametypes/repeated.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def generate_samples(
game_setup: GameSetup[CT, PT, RT],
) -> Iterable[Tuple[float, float, Optional[List[Choices[CT]]], List[str]]]:
# pylint: disable=R0801
for _i in range(measurement_setup.num_samples):
for __i__ in range(measurement_setup.num_samples):
conversation = play_game(
partner_strategy=partner_strategy,
participant_condition=condition,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_alternating.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_analyse_round(
expected_choices: Choices,
alternating_history,
):
_scores, choices = alternating.analyse_round(
__scores__, choices = alternating.analyse_round(
i, alternating_history, payoffs_ultimatum, extract_choice_ultimatum
)
assert choices == expected_choices
Expand Down
2 changes: 1 addition & 1 deletion tests/test_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_run_and_record_experiment(mocker):
name = "test_experiment"
run_and_record_experiment(
name,
run=lambda _setup, _n: results_mock,
run=lambda __setup__, __n__: results_mock,
model_setup=DEFAULT_MODEL_SETUP,
sample_size=DEFAULT_SAMPLE_SIZE,
)
Expand Down

0 comments on commit 5e261d4

Please sign in to comment.