id
stringlengths
30
32
content
stringlengths
139
2.8k
codereview_new_python_data_6028
def test_get_parameters_by_path_and_filter_by_labels(self, ssm_client, create_pa assert found_param["Type"] == "String" assert found_param["Value"] == "value" def test_get_inexistent_maintenance_window(self, ssm_client): invalid_name = "mw-00000000000000000" with pytest.raise...
codereview_new_python_data_6029
class LocalKmsProvider(KmsApi, ServiceLifecycleHook): - def get_forward_url(self): - """Return the URL of the backend local-kms server to forward requests to""" account_id = get_aws_account_id() start_kms_local(account_id=account_id) return f"http://{LOCALSTACK_HOSTNAME}:{get_...
codereview_new_python_data_6030
class ResourcePolicy: @dataclasses.dataclass class FunctionResourcePolicy: - # TODO: do we have a typed IAM policy somewhere already? - # Something like this? localstack_ext.services.iam.policy_engine.models.PolicyDocument policy: ResourcePolicy ```suggestion ``` I'd just remove this for now. T...
codereview_new_python_data_6031
def in_docker(): # TODO change when asf becomes default: os.environ.get("PROVIDER_OVERRIDE_S3", "") == 'legacy' LEGACY_S3_PROVIDER = os.environ.get("PROVIDER_OVERRIDE_S3", "") not in ("asf", "asf_pro") -# Whether to use the legacy implementation for AWS StepFunctions. -LEGACY_SFN_PROVIDER = os.environ.get("PROVIDE...
codereview_new_python_data_6032
class ExecutionWorkerComm(abc.ABC): @abc.abstractmethod def terminated(self) -> None: ... nit: Would be great if we could add a few docstrings to explain the purpose/responsibility of the core engine classes. For the most part, the name is already self-explanatory, but it cannot harm to ad...
codereview_new_python_data_6033
def test_create_rest_api_with_custom_id( assert response.ok assert response._content == b'{"echo": "foobar", "response": "mocked"}' - @pytest.mark.skip def test_api_gateway_kinesis_integration(self): # create target Kinesis stream stream = resource_util.create_kinesis_stre...
codereview_new_python_data_6034
-import os - -# parent directory of this file -PARENT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -OPENAPI_SPEC_PULUMI_JSON = os.path.join(PARENT_DIR, "files", "openapi.spec.pulumi.json") nit: we usually keep the `__init__.py` files clean of custom logic. Not critical, as this is just a test mod...
codereview_new_python_data_6035
def validate_kms_key_id(kms_key: str, bucket: FakeBucket): arn = parse_arn(kms_key) region_name = arn["region"] if region_name != bucket.region_name: - raise # multi account unsupported yet except InvalidArnException: pass Shouldn't we raise `KMS:NotFoundEx...
codereview_new_python_data_6036
def test_lambda_permission_url_invocation( create_lambda_function( func_name=function_name, zip_file=testutil.create_zip_file(TEST_LAMBDA_URL, get_content=True), - runtime=Runtime.nodejs14_x, handler="lambda_url.handler", ) url_config = lambd...
codereview_new_python_data_6037
from moto.logs.models import LogsBackend as MotoLogsBackend from moto.logs.models import logs_backends as moto_logs_backend -from localstack.constants import DEFAULT_AWS_ACCOUNT_ID from localstack.services.stores import AccountRegionBundle, BaseStore, CrossRegionAttribute -from localstack.utils.aws import aws_sta...
codereview_new_python_data_6038
def start(self, env_vars: dict[str, str]) -> None: container_name_or_id=self.id, container_network=network ) if config.LAMBDA_ASF_DEV_PORT_EXPOSE: - self.executor_endpoint.container_address = "localhost" - else: - self.executor_endpoint.container_address = se...
codereview_new_python_data_6039
def test_put_object(self, s3_client, s3_bucket, snapshot): snapshot.match("get_object", response) @pytest.mark.aws_validated def test_post_object_with_files(self, s3_client, s3_bucket): object_key = "test-presigned-post-key" Like we discussed, those presigned POST tests are very flaky,...
codereview_new_python_data_6040
def _create_version_model( id=new_id, ) function.versions[next_version] = new_version if "$LATEST" in function.permissions: function.permissions[ "$LATEST" nit: Would be great if you could add a 1-2 line comment here explain...
codereview_new_python_data_6041
# Default bucket name of the s3 bucket used for local lambda development # This name should be accepted by all IaC tools, so should respect s3 bucket naming conventions -DEFAULT_BUCKET_MARKER_LOCAL = "hot-reloading-bucket" -OLD_DEFAULT_BUCKET_MARKER_LOCAL = "__local__" # user that starts the opensearch process ...
codereview_new_python_data_6042
# Default bucket name of the s3 bucket used for local lambda development # This name should be accepted by all IaC tools, so should respect s3 bucket naming conventions -DEFAULT_BUCKET_MARKER_LOCAL = "hot-reloading-bucket" -OLD_DEFAULT_BUCKET_MARKER_LOCAL = "__local__" # user that starts the opensearch process ...
codereview_new_python_data_6043
def _run_transcription_job(self, args: Tuple[TranscribeStore, str]): job["FailureReason"] = failure_reason or str(exc) job["TranscriptionJobStatus"] = TranscriptionJobStatus.FAILED - LOG.warning("Transcription job %s failed: %s", job_name, job["FailureReason"]) - - rai...
codereview_new_python_data_6044
def start(self, env_vars: dict[str, str]) -> None: def stop(self) -> None: CONTAINER_CLIENT.stop_container(container_name=self.id, timeout=5) - # CONTAINER_CLIENT.remove_container(container_name=self.id) try: self.executor_endpoint.shutdown() except Exception as e:...
codereview_new_python_data_6045
def _assert_batch(self, batch: List) -> None: raise EmptyBatchRequest visited = set() for entry in batch: - if not re.search(r"^[\w-]+$", (entry_id := entry["Id"])) or len(entry_id) > 80: raise InvalidBatchEntryId( "A batch entry id can on...
codereview_new_python_data_6046
def handler(event, context): fragment["Resources"]["Parameter"]["Properties"]["Value"] = json.dumps( { "Event": event, - # TODO find a way to print context class - # "Context": vars(context) } ) Is there anything specific in the context that we would be...
codereview_new_python_data_6047
def test_to_validate_template_limit_for_macro( snapshot, ): """ - The test validates the template max size that can be pass into the create_template """ macro_function_path = os.path.join( os.path.dirname(__file__), "../templates/macros/format_template.py" ...
codereview_new_python_data_6048
def test_to_validate_template_limit_for_macro( snapshot, ): """ - The test validates the template max size that can be pass into the create_template """ macro_function_path = os.path.join( os.path.dirname(__file__), "../templates/macros/format_template.py" ...
codereview_new_python_data_6049
def fix_types(o, **kwargs): def log_not_available_message(resource_type: str, message: str): LOG.warning( f"{message}. To find out if {resource_type} is supported in LocalStack Pro, " - "please check out our docs at https://docs.localstack.cloud/user-guide/aws/cloudformation/" ) ```sugg...
codereview_new_python_data_6050
def test_cfn_with_apigateway_resources(deploy_cfn_template, apigateway_client): "$..version", "$..methodIntegration.cacheNamespace", "$..methodIntegration.connectionType", - "$..methodIntegration.integrationResponses", "$..methodIntegration.passthroughBehavior", "$.....
codereview_new_python_data_6051
def publish( elif phone_number: self._publisher.publish_to_phone_number(ctx=publish_ctx, phone_number=phone_number) else: - # TODO: beware if FIFO, order is guaranteed yet. Semaphore? might block workers - # 2 quick call in succession might be unordered in the execu...
codereview_new_python_data_6052
def test_publish_sms(self, sns_client): @pytest.mark.aws_validated def test_publish_non_existent_target(self, sns_client, sns_create_topic, snapshot): - # todo: fix test, the client id in the ARN is wrong so can't test against AWS topic_arn = sns_create_topic()["TopicArn"] account_...
codereview_new_python_data_6053
def store_s3_bucket_archive( ) -def store_image_code(image_uri: str) -> ImageCode: """ Creates an image code by inspecting the provided image ```suggestion def create_image_code(image_uri: str) -> ImageCode: ``` nit: doesn't seem to store anything :thinking: def store_s3_bucket_archive( ...
codereview_new_python_data_6054
def on_before_stop(self): pass def on_after_inject(self): - """Hook triggered after a new state in injected.""" pass def on_exception(self): tiny typo nit: ```suggestion """Hook triggered after new state has been injected into the provider's store.""" ``` def on_bef...
codereview_new_python_data_6055
def get_docker_image_to_start(): image_name = constants.DOCKER_IMAGE_NAME if os.environ.get("USE_LIGHT_IMAGE") in constants.FALSE_STRINGS: image_name = constants.DOCKER_IMAGE_NAME_FULL - if os.environ.get("LOCALSTACK_API_KEY"): image_name = constants.DOCKER_IMAGE_NAME...
codereview_new_python_data_6056
def test_head_object_fields(self, s3_client, s3_bucket, snapshot): snapshot.match("head-object", response) @pytest.mark.aws_validated def test_get_object_after_deleted_in_versioned_bucket( self, s3_client, s3_bucket, s3_resource, snapshot ): ```suggestion @pytest.mark.aws_valid...
codereview_new_python_data_6057
"python3.7": "python:3.7@sha256:be668898a538d5258e006e1920f86f31cab8000dfa68b3be78d5ef67ad15a417", "python3.8": "python:3.8@sha256:b3402a5f5e9535ba4787a1fd6b0ee39738dee18bdff861a0589571ba74122d35", "python3.9": "python:3.9@sha256:5b3585b121e6fb9707abb52c1f99cbab51939fee0769752ab6c641f20f479cf6", - "n...
codereview_new_python_data_6058
def test_sam_template(lambda_client, deploy_cfn_template): parameters={"FunctionName": func_name}, ) - lambda_client.get_waiter("function_active_v2").wait( - FunctionName=func_name - ) # TODO: fix cfn model instead - # run Lambda test invocation result = lambda_client.invoke(Fun...
codereview_new_python_data_6059
def call_lambda(function_arn: str, event: bytes, asynchronous: bool) -> str: lambda_client = aws_stack.connect_to_service( "lambda", region_name=extract_region_from_arn(function_arn) ) - lambda_client.get_waiter("function_active_v2").wait(FunctionName=function_arn) inv_result = lambda_client...
codereview_new_python_data_6060
def test_lifecycle_nested_stack(cfn_client, deploy_cfn_template, s3_client, s3_c assert s3_client.head_bucket(Bucket=altered_nested_bucket_name) - cfn_client.delete_stack(StackName=stack.stack_name) def _assert_bucket_is_deleted(): try: FYI: there's a convenience function that you *can* us...
codereview_new_python_data_6061
def set_aws_account_id(account_id: str) -> None: def get_account_id_from_access_key_id(access_key_id: str) -> str: """Return the Account ID associated the Access Key ID.""" - # If AWS_ACCES_KEY_ID has a 12-digit integer value, use it as the account ID if re.match(r"\d{12}", access_key_id): ret...
codereview_new_python_data_6062
def put_bucket_cors( expected_bucket_owner: AccountId = None, ) -> None: response = call_moto(context) - # max 100 rules - # validate CORS? see moto self.get_store().bucket_cors[bucket] = cors_configuration self._cors_handler.invalidate_cache() return res...
codereview_new_python_data_6063
def publish_version(self, function_version: FunctionVersion): """ Synchronously create a function version (manager) Should only be called on publishing new versions, which basically clone an existing one. - The published version should already be contained in the lambda state. ...
codereview_new_python_data_6064
def do_execute(q): start_time = now(millis=True) process.start() try: - process_result: LocalExecutorResult = process_queue.get(timeout=20) except queue.Empty: process_result = LocalExecutorResult( "", ```suggestion process_resu...
codereview_new_python_data_6065
def _create(resource_id, resources, resource_type, func, stack_name): resource = resources[resource_id] props = resource["Properties"] - tag_list = props.get("Tags", []) - tag_map = {tag["Key"]: tag["Value"] for tag in tag_list} # TODO: add missing attri...
codereview_new_python_data_6066
def post_object( try: response: PostResponse = call_moto(context=context) except ServiceException as e: - if e.code == "303": - response = PostResponse(StatusCode=303) else: raise e nit: should probably be ```suggestion ...
codereview_new_python_data_6067
def _extract_service_indicators(request: Request) -> _ServiceIndicators: "/2021-01-01": "opensearch", }, "sagemaker": { - "/endpoints/": "sagemaker-runtime", "/human-loops": "sagemaker-a2i-runtime", }, } Does it make a difference here if we add `"/endpoints/"` instead of `"/en...
codereview_new_python_data_6068
def cmd_start(docker: bool, host: bool, no_banner: bool, detached: bool): try: bootstrap.start_infra_locally() except ImportError: raise click.ClickException( "It appears you have a light install of localstack which only supports running in docker\n" ...
codereview_new_python_data_6069
def get_cfn_attribute(self, attribute_name): if attribute_name == "WebsiteURL": bucket_name = self.props.get("BucketName") - return f"http://{bucket_name}.{S3_STATIC_WEBSITE_HOSTNAME}" return super(S3Bucket, self).get_cfn_attribute(attribute_name) nit: technically the s...
codereview_new_python_data_6070
class NoSuchVersionException(PackageException): pass -class UnsupportedOSException(PackageException): - """Exception indicating that the requested package does not exist for the used operating system""" - - pass - - -class UnsupportedArchException(PackageException): - """Exception indicating that the...
codereview_new_python_data_6071
def _install(self, target: InstallTarget) -> None: ) -class PermissionDownloadInstaller(DownloadInstaller): - def _get_download_url(self) -> str: - raise NotImplementedError() - def _install(self, target: InstallTarget) -> None: super()._install(target) chmod_r(self.get_ex...
codereview_new_python_data_6072
def _install(self, target: InstallTarget) -> None: terraform_package = TerraformPackage() -TERRAFORM_BIN = terraform_package.get_installer().get_executable_path() This line needs to be removed. The binary location needs to be evaluated at runtime when the binary is needed (or at least after it is ensured that it...
codereview_new_python_data_6073
def is_none_or_empty(obj: Union[Optional[str], Optional[list]]) -> bool: def select_from_typed_dict(typed_dict: Type[TypedDict], obj: Dict, filter: bool = False) -> Dict: - """Select a subset of attributes from a dictionary based on the keys of a given `TypedDict`""" selection = select_attributes( ...
codereview_new_python_data_6074
class FunctionUrlConfig: class VersionFunctionConfiguration: # fields # name: str - function_arn: str # TODO:? description: str role: str timeout: int Out of curiosity, what's the required change (TODO) here? class FunctionUrlConfig: class VersionFunctionConfiguration: # fields ...
codereview_new_python_data_6075
def store_s3_bucket_archive( account_id: str, ) -> S3Code: """ - Takes the lambda archive stored in the given bucket and stores it in an internal s4 bucket :param archive_bucket: Bucket the archive is stored in :param archive_key: Key the archive is stored under ```suggestion Takes the ...
codereview_new_python_data_6076
def qualifier_exists(self, qualifier): @property def envvars(self): return self._envvars @envvars.setter It would be nice if you can add a docstring here (we use reStructuredText usually) to document this condition. def qualifier_exists(self, qualifier): @property def envvars...
codereview_new_python_data_6077
def _assert_transcript(): content = to_str(data["Body"].read()) assert "hello my name is" in content - retry(_assert_transcript, retries=10, sleep=3) def test_transcribe_unsupported_media_format_failure( self, transcribe_client, transcribe_create_job I fear this will...
codereview_new_python_data_6078
) STEPFUNCTIONS_ZIP_URL = "https://s3.amazonaws.com/stepfunctionslocal/StepFunctionsLocal.zip" KMS_URL_PATTERN = "https://s3-eu-west-2.amazonaws.com/local-kms/3/local-kms_<arch>.bin" -FFMPEG_STATIC_BIN_URL = ( - "https://www.johnvansickle.com/ffmpeg/old-releases/ffmpeg-{version}-{arch}-static.tar.xz" -) # API...
codereview_new_python_data_6079
def test_lambda_cache_local( second_invoke_result = lambda_client.invoke(FunctionName=func_name) snapshot.match("second_invoke_result", second_invoke_result) - @pytest.mark.skip_snapshot_verify( - condition=is_old_provider, - paths=["$..FunctionError", "$..LogResult", "$..Payload",...
codereview_new_python_data_6080
def run_app_sync(*args, loop=None, shutdown_event=None): class ProxyThread(FuncThread): def __init__(self): - FuncThread.__init__(self, self.run_proxy, None, name="proxy-thread") # TODO self.shutdown_event = None self.loop = None Seems like a TODO slipped throug...
codereview_new_python_data_6081
def stop(self, quiet: bool = False) -> None: def start_thread(method, *args, **kwargs) -> FuncThread: # TODO: find all usages and add names... """Start the given method in a background thread, and add the thread to the TMP_THREADS shutdown hook""" _shutdown_hook = kwargs.pop("_shutdown_hook", True) - # ...
codereview_new_python_data_6082
def run_app_sync(*args, loop=None, shutdown_event=None): class ProxyThread(FuncThread): def __init__(self): - FuncThread.__init__(self, self.run_proxy, None, name="proxy-thread") # TODO self.shutdown_event = None self.loop = None What's TODO here? def run_app_...
codereview_new_python_data_6083
def _create_apigateway_function(*args, **kwargs): @pytest.fixture -def import_apigateway_function(apigateway_client): rest_api_ids = [] def _import_apigateway_function(*args, **kwargs): nit: I guess the same could apply to shortening the name of this fixture.. 😅 (don't bother for this PR, though - c...
codereview_new_python_data_6084
def inline_policy_unapply_policy(fn, self, backend): except Exception: # Actually role can be deleted before policy being deleted in cloudformation pass - - @patch(IAMBackend.create_policy) - def clean_policy_document_from_no_values( - fn, self, description, path, policy...
codereview_new_python_data_6085
import pytest -# TODO fix service so it returns the stream mode @pytest.mark.aws_validated @pytest.mark.skip_snapshot_verify(paths=["$..StreamDescription.StreamModeDetails"]) def test_stream_creation(kinesis_client, deploy_cfn_template, snapshot): ```suggestion ``` The paths in `skips_snapshot_verify` alrea...
codereview_new_python_data_6086
def factory(**kwargs): @pytest.fixture def transcribe_create_job(transcribe_client, s3_client, s3_bucket): def _create_job(**kwargs): if "TranscriptionJobName" not in kwargs: kwargs["TranscriptionJobName"] = f"test-transcribe-{short_uid()}" if "LanguageCode" not in kwargs: ...
codereview_new_python_data_6087
def factory(**kwargs): @pytest.fixture def transcribe_create_job(transcribe_client, s3_client, s3_bucket): def _create_job(**kwargs): if "TranscriptionJobName" not in kwargs: kwargs["TranscriptionJobName"] = f"test-transcribe-{short_uid()}" if "LanguageCode" not in kwargs: ...
codereview_new_python_data_6088
def delete_change_set( change_set.stack.change_sets = [ cs for cs in change_set.stack.change_sets - if (cs.change_set_name != change_set_name and cs.change_set_id != change_set_name) ] return DeleteChangeSetOutput() tiny nit: could be simplified a bit ...
codereview_new_python_data_6089
def test_default_logging_configuration( assert result["ResponseMetadata"]["HTTPStatusCode"] == 200 result = stepfunctions_client.describe_state_machine(stateMachineArn=result["stateMachineArn"]) assert result["ResponseMetadata"]["HTTPStatusCode"] == 200 - assert result["loggingConfiguration"] as...
codereview_new_python_data_6090
def test_report_batch_item_failures_invalid_result_json_batch_fails( assert "Messages" in first_invocation snapshot.match("first_invocation", first_invocation) - # now wait for the second invocation result which second_invocation = sqs_client.receive_message( QueueUrl=destination_url, Wait...
codereview_new_python_data_6091
def match(self, key: str, obj: dict) -> None: self.called_keys.add(key) # order the obj to guarantee reference replacement works as expected - self.observed_state[key] = ( - self._order_dict(obj) if isinstance(obj, dict) else obj - ) # type is not enforced, we already have...
codereview_new_python_data_6092
def send_notification_for_subscriber( try: events_client.put_events(Entries=[entry]) except Exception as e: - LOGGER.warning( - f'Unable to send notification for S3 bucket "{bucket_name}" to EventBridge', e ) if not filter(lambda x: notificat...
codereview_new_python_data_6093
from jsonpath_ng.ext import parse SNAPSHOT_LOGGER = logging.getLogger(__name__) -SNAPSHOT_LOGGER.setLevel(logging.DEBUG if os.environ.get("SNAPSHOT_DEBUG") else logging.WARNING) # Types i think `SNAPSHOT_DEBUG` is better than `DEBUG_SNAPSHOT` (since the first specifies the namepsace of the property), however...
codereview_new_python_data_6094
def invoke(self, api_context: ApiInvocationContext): EVENTBRIDGE_PUTEVENTS = "EventBridge-PutEvents", False SQS_SENDMESSAGE = "SQS-SendMessage", False - SQS_RECEIVESMESSAGE = "SQS-ReceiveMessage", False SQS_DELETEMESSAGE = "SQS-DeleteMessage", False SQS_PURGEQUEUE = "SQS-PurgeQueue", False ...
codereview_new_python_data_6095
import pytest -from localstack.utils.common import retry -from localstack.utils.common import safe_requests as requests -from localstack.utils.common import short_uid THIS_FOLDER = os.path.dirname(os.path.realpath(__file__)) TEST_LAMBDA_PYTHON_TRIGGERED_S3 = os.path.join( Please do not import directly from ....
codereview_new_python_data_6096
def cmd_logs(follow: bool): if not DOCKER_CLIENT.is_container_running(container_name): console.print("localstack container not running") - with open(logfile) as fd: - for line in fd: - console.print(line.rstrip("\n\r")) sys.exit(1) if follow: We should ...
codereview_new_python_data_6111
def test_contains_product(self): ranges = models.Range.objects.contains_product(self.prod) self.assertEqual(ranges.count(), 2, "Both ranges should contain the product") - def test_not_contains_non_public_product(self): - product = create_product() - self.range.add_product(product) ...
codereview_new_python_data_6112
def products(self): return Product.objects.none() queryset = self.condition.range.all_products() - return queryset.filter(is_discountable=True).exclude( - structure=Product.CHILD).browsable() @cached_property def combined_offers(self): En then you can remove the ....
codereview_new_python_data_6113
DEFAULT_HASHING_ALGORITHM = 'sha1' TEST_RUNNER = 'django.test.runner.DiscoverRunner' FIXTURE_DIRS = [location('unit/fixtures')] - -# Try and import local settings which can be used to override any of the above. -try: - from tests.settings_local import * -except ImportError: - pass I think you committed this...
codereview_new_python_data_6116
class _LGBMRegressorBase: # type: ignore _LGBMBaseCrossValidator = None _LGBMLabelEncoder = None - _LGBMBaseCrossValidator = None LGBMNotFittedError = ValueError _LGBMStratifiedKFold = None _LGBMGroupKFold = None This is already included above ```suggestion ``` class _LGBMRegressorB...
codereview_new_python_data_6117
This script checks that LightGBM library is linked to the appropriate symbol versions. Linking to newer symbol versions at compile time is problematic because it could result -in built artifacts being unusable on older platforms that LightGBM users are on. Version history for these symbols can be found at the f...
codereview_new_python_data_6118
def fit( feature_name='auto', categorical_feature='auto', callbacks=None, - init_model: Optional[Union[str, Path, Booster, LGBMModel]] = None ): """Docstring is set after definition, using a template.""" params = self._process_params(stage="fit") ```suggestion ...
codereview_new_python_data_6119
def dummy_metric(_, __): "INFO | [LightGBM] [Info] LightGBM using CUDA trainer with DP float!!" ] cuda_exp_lines = [ - "INFO | [LightGBM] [Warning] Using sparse features with CUDA is currently not supported.", "INFO | [LightGBM] [Warning] Objective binary is not implemented in cuda_e...
codereview_new_python_data_6120
def test_chunked_dataset_linear(): def test_save_dataset_subset_and_load_from_file(tmp_path): data = np.random.rand(100, 2) - ds = lgb.Dataset(data) ds.subset([1, 2, 3, 5, 8]).save_binary(tmp_path / 'subset.bin') - lgb.Dataset(tmp_path / 'subset.bin').construct() def test_subset_group(): Could...
codereview_new_python_data_6129
def _make_n_folds( def _agg_cv_result( - raw_results: List[Tuple[str, str, float, bool]] ) -> List[Tuple[str, str, float, bool, float]]: """Aggregate cross-validation results.""" cvmap = collections.OrderedDict() You can see two `for` loops iterating over two lists here: https://github.com/microso...
codereview_new_python_data_6132
def _choose_param_value(main_param_name: str, params: Dict[str, Any], default_va # avoid side effects on passed-in parameters params = deepcopy(params) - aliases = set(_ConfigAliases.get(main_param_name)) - {main_param_name} # if main_param_name was provided, keep that value and remove all aliase...
codereview_new_python_data_6133
def test_no_copy_when_single_float_dtype_dataframe(dtype, feature_name): assert np.shares_memory(X, built_data) -@pytest.mark.parametrize('feature_name', [[42], 'auto']) def test_categorical_code_conversion_doesnt_modify_original_data(feature_name): pd = pytest.importorskip('pandas') X = np.random....
codereview_new_python_data_6234
def get_bonus(self, stability: float) -> float: return self.value if stability >= self.required_stability else 0.0 -def adjust_direction(threshold: float, current: float, target) -> float: """ Returns -1, 0 or 1, depending on whether compared to current, target drops below, is on the same side o...
codereview_new_python_data_6235
def set_have_nest(): def have_computronium() -> bool: - """Do we have a planet with a computronium moon, which is set to research focus?""" return _get_planet_catalog().have_computronium def computronium_candidates() -> List[PlanetId]: - """Returns list of own planets that have a computronium moon...
codereview_new_python_data_6236
def set_have_nest(): def have_computronium() -> bool: - """Do we have a planet with a computronium moon, which is set to research focus?""" return _get_planet_catalog().have_computronium def computronium_candidates() -> List[PlanetId]: - """Returns list of own planets that have a computronium moon...
codereview_new_python_data_6237
def set_planet_industry_research_influence_foci(focus_manager, priority_ratio): # xy = y output when focus x, p for production(INDUSTRY), c for current pp, pr, pi = pinfo.possible_output[INDUSTRY] rp, rr, ri = pinfo.possible_output[RESEARCH] # calculate factor F at w...
codereview_new_python_data_6242
class Bonus(NamedTuple): def get_bonus(self, stability: float) -> float: if not self.available: return 0.0 - return self.value if stability > self.min_stability else 0.0 ```suggestion if not self.available or stability < self.min_stability: return 0.0 r...
codereview_new_python_data_6243
class Tags: # </editor-fold> # <editor-fold desc="Industry boosting specials"> -# modified = affected by species multiplier industry_boost_specials_modified = { "TIDAL_LOCK_SPECIAL", } industry_boost_specials_unmodified = { "CRYSTALS_SPECIAL", "ELERIUM_SPECIAL", Maybe use `fixed`/`flat` and `mul...
codereview_new_python_data_6261
def test_s2nd_falls_back_to_full_connection(managed_process, tmp_path, cipher, c @pytest.mark.parametrize("cipher", ALL_TEST_CIPHERS, ids=get_parameter_name) @pytest.mark.parametrize("curve", ALL_TEST_CURVES, ids=get_parameter_name) @pytest.mark.parametrize("certificate", ALL_TEST_CERTS, ids=get_parameter_name) -@p...
codereview_new_python_data_6315
class Ciphers(object): "PQ-SIKE-TEST-TLS-1-0-2020-02", Protocols.TLS10, False, False, s2n=True, pq=True) PQ_TLS_1_0_2020_12 = Cipher( "PQ-TLS-1-0-2020-12", Protocols.TLS10, False, False, s2n=True, pq=True) - DEFAULT_FIPS = Cipher( - "default_fips", Protocols.TLS12, False, True, s2n=Tru...
codereview_new_python_data_6316
class Ciphers(object): "PQ-SIKE-TEST-TLS-1-0-2020-02", Protocols.TLS10, False, False, s2n=True, pq=True) PQ_TLS_1_0_2020_12 = Cipher( "PQ-TLS-1-0-2020-12", Protocols.TLS10, False, False, s2n=True, pq=True) SECURITY_POLICY_20210816 = Cipher( - "20210816", Protocols.TLS12, False, False...
codereview_new_python_data_6317
def expected_signature(protocol, signature): signature = signature return signature -# ECDSA by default hashes with SHA-1. -# -# This is inferred from the rfc- https://www.rfc-editor.org/rfc/rfc4492#section-5.10 def expected_signature_alg_tls12(signature): if signature == Signatures.RSA_SHA224: ...
codereview_new_python_data_6318
class Signatures(object): RSA_SHA256 = Signature('RSA+SHA256', max_protocol=Protocols.TLS12) RSA_SHA384 = Signature('RSA+SHA384', max_protocol=Protocols.TLS12) RSA_SHA512 = Signature('RSA+SHA512', max_protocol=Protocols.TLS12) - MD5_SHA1 = Signature('RSA+MD5_SHA1', max_protocol=Protocols.TLS11) ...
codereview_new_python_data_6319
-from common import Protocols, Signatures from providers import S2N from global_flags import get_flag, S2N_FIPS_MODE ## Unused import Import of 'Signatures' is not used. [Show more details](https://github.com/aws/s2n-tls/security/code-scanning/561) +from common import Protocols from providers import S2N fro...
codereview_new_python_data_6320
def test_s2n_server_tls12_signature_algorithm_fallback(managed_process, cipher, # extension. # # This is inferred from the rfc- https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.4.1 - expected_sig_alg_tls12: None if signature == Signatures.RSA_SHA224: expected_sig_alg_tls12 = Signatu...
codereview_new_python_data_6321
def test_s2n_server_tls12_signature_algorithm_fallback(managed_process, cipher, # extension. # # This is inferred from the rfc- https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.4.1 - expected_sig_alg_tls12: None if signature == Signatures.RSA_SHA224: expected_sig_alg_tls12 = Signatu...
codereview_new_python_data_6322
import pytest from configuration import available_ports, TLS13_CIPHERS, ALL_TEST_CURVES, MINIMAL_TEST_CERTS -from common import Ciphers, ProviderOptions, Protocols, data_bytes from fixtures import managed_process # lgtm [py/unused-import] from providers import Provider, S2N, OpenSSL from utils import invalid_t...
codereview_new_python_data_6323
import copy -import math import pytest from configuration import available_ports, TLS13_CIPHERS, ALL_TEST_CURVES, MINIMAL_TEST_CERTS ## Unused import Import of 'math' is not used. [Show more details](https://github.com/aws/s2n-tls/security/code-scanning/553) import copy import pytest from configuration ...
codereview_new_python_data_6325
import copy import pytest -import math import re from configuration import available_ports, TLS13_CIPHERS, ALL_TEST_CURVES, MINIMAL_TEST_CERTS ## Unused import Import of 'math' is not used. [Show more details](https://github.com/aws/s2n-tls/security/code-scanning/554) import copy import pytest import re ...
codereview_new_python_data_6338
SEARCH_USER_LIMIT = 10 -@api_bp.route('/playlist/search/users/', methods=['GET', 'OPTIONS']) @crossdomain @ratelimit() def search_user(): search_term = request.args.get("search_term") user = validate_auth_header() user_id = user.id if search_term: - users = db_user.search(search_term...
codereview_new_python_data_6339
@ratelimit() def search_user(): search_term = request.args.get("search_term") - validate_auth_header() if search_term: users = db_user.search_user_name(search_term, SEARCH_USER_LIMIT) else: users = [] return jsonify( { - 'status': 'ok', 'users...
codereview_new_python_data_6340
@ratelimit() def search_user(): search_term = request.args.get("search_term") - validate_auth_header() if search_term: users = db_user.search_user_name(search_term, SEARCH_USER_LIMIT) else: users = [] return jsonify( { - 'status': 'ok', 'users...