after_merge
stringlengths
28
79.6k
before_merge
stringlengths
20
79.6k
url
stringlengths
38
71
full_traceback
stringlengths
43
922k
traceback_type
stringclasses
555 values
def create_kwargs( constructor: Callable[..., T], cls: Type[T], params: Params, **extras ) -> Dict[str, Any]: """ Given some class, a `Params` object, and potentially other keyword arguments, create a dict of keyword args suitable for passing to the class's constructor. The function does this by finding the class's constructor, matching the constructor arguments to entries in the `params` object, and instantiating values for the parameters using the type annotation and possibly a from_params method. Any values that are provided in the `extras` will just be used as is. For instance, you might provide an existing `Vocabulary` this way. """ # Get the signature of the constructor. kwargs: Dict[str, Any] = {} parameters = infer_params(cls, constructor) accepts_kwargs = False # Iterate over all the constructor parameters and their annotations. for param_name, param in parameters.items(): # Skip "self". You're not *required* to call the first parameter "self", # so in theory this logic is fragile, but if you don't call the self parameter # "self" you kind of deserve what happens. if param_name == "self": continue if param.kind == param.VAR_KEYWORD: # When a class takes **kwargs, we do two things: first, we assume that the **kwargs are # getting passed to the super class, so we inspect super class constructors to get # allowed arguments (that happens in `infer_params` above). Second, we store the fact # that the method allows extra keys; if we get extra parameters, instead of crashing, # we'll just pass them as-is to the constructor, and hope that you know what you're # doing. accepts_kwargs = True continue # If the annotation is a compound type like typing.Dict[str, int], # it will have an __origin__ field indicating `typing.Dict` # and an __args__ field indicating `(str, int)`. We capture both. annotation = remove_optional(param.annotation) constructed_arg = pop_and_construct_arg( cls.__name__, param_name, annotation, param.default, params, **extras ) # If we just ended up constructing the default value for the parameter, we can just omit it. # Leaving it in can cause issues with **kwargs in some corner cases, where you might end up # with multiple values for a single parameter (e.g., the default value gives you lazy=False # for a dataset reader inside **kwargs, but a particular dataset reader actually hard-codes # lazy=True - the superclass sees both lazy=True and lazy=False in its constructor). if constructed_arg is not param.default: kwargs[param_name] = constructed_arg if accepts_kwargs: kwargs.update(params) else: params.assert_empty(cls.__name__) return kwargs
def create_kwargs( constructor: Callable[..., T], cls: Type[T], params: Params, **extras ) -> Dict[str, Any]: """ Given some class, a `Params` object, and potentially other keyword arguments, create a dict of keyword args suitable for passing to the class's constructor. The function does this by finding the class's constructor, matching the constructor arguments to entries in the `params` object, and instantiating values for the parameters using the type annotation and possibly a from_params method. Any values that are provided in the `extras` will just be used as is. For instance, you might provide an existing `Vocabulary` this way. """ # Get the signature of the constructor. kwargs: Dict[str, Any] = {} parameters = infer_params(cls, constructor) # Iterate over all the constructor parameters and their annotations. for param_name, param in parameters.items(): # Skip "self". You're not *required* to call the first parameter "self", # so in theory this logic is fragile, but if you don't call the self parameter # "self" you kind of deserve what happens. if param_name == "self": continue # Also skip **kwargs parameters; we handled them above. if param.kind == param.VAR_KEYWORD: continue # If the annotation is a compound type like typing.Dict[str, int], # it will have an __origin__ field indicating `typing.Dict` # and an __args__ field indicating `(str, int)`. We capture both. annotation = remove_optional(param.annotation) constructed_arg = pop_and_construct_arg( cls.__name__, param_name, annotation, param.default, params, **extras ) # If we just ended up constructing the default value for the parameter, we can just omit it. # Leaving it in can cause issues with **kwargs in some corner cases, where you might end up # with multiple values for a single parameter (e.g., the default value gives you lazy=False # for a dataset reader inside **kwargs, but a particular dataset reader actually hard-codes # lazy=True - the superclass sees both lazy=True and lazy=False in its constructor). if constructed_arg is not param.default: kwargs[param_name] = constructed_arg params.assert_empty(cls.__name__) return kwargs
https://github.com/allenai/allennlp/issues/4614
Traceback (most recent call last): File "tmp.py", line 10, in <module> Foo.from_params(Params({"a": 2, "b": "hi"})) File "/Users/evanw/AllenAI/allennlp/allennlp/common/from_params.py", line 610, in from_params kwargs = create_kwargs(constructor_to_inspect, cls, params, **extras) File "/Users/evanw/AllenAI/allennlp/allennlp/common/from_params.py", line 163, in create_kwargs parameters = infer_params(cls, constructor) File "/Users/evanw/AllenAI/allennlp/allennlp/common/from_params.py", line 140, in infer_params super_parameters = infer_params(super_class) File "/Users/evanw/AllenAI/allennlp/allennlp/common/from_params.py", line 139, in infer_params raise RuntimeError("found a kwargs parameter with no inspectable super class") RuntimeError: found a kwargs parameter with no inspectable super class
RuntimeError
def from_params( cls: Type[T], params: Params, constructor_to_call: Callable[..., T] = None, constructor_to_inspect: Callable[..., T] = None, **extras, ) -> T: """ This is the automatic implementation of `from_params`. Any class that subclasses `FromParams` (or `Registrable`, which itself subclasses `FromParams`) gets this implementation for free. If you want your class to be instantiated from params in the "obvious" way -- pop off parameters and hand them to your constructor with the same names -- this provides that functionality. If you need more complex logic in your from `from_params` method, you'll have to implement your own method that overrides this one. The `constructor_to_call` and `constructor_to_inspect` arguments deal with a bit of redirection that we do. We allow you to register particular `@classmethods` on a class as the constructor to use for a registered name. This lets you, e.g., have a single `Vocabulary` class that can be constructed in two different ways, with different names registered to each constructor. In order to handle this, we need to know not just the class we're trying to construct (`cls`), but also what method we should inspect to find its arguments (`constructor_to_inspect`), and what method to call when we're done constructing arguments (`constructor_to_call`). These two methods are the same when you've used a `@classmethod` as your constructor, but they are `different` when you use the default constructor (because you inspect `__init__`, but call `cls()`). """ from allennlp.common.registrable import ( Registrable, ) # import here to avoid circular imports logger.debug( f"instantiating class {cls} from params {getattr(params, 'params', params)} " f"and extras {set(extras.keys())}" ) if params is None: return None if isinstance(params, str): params = Params({"type": params}) if not isinstance(params, Params): raise ConfigurationError( "from_params was passed a `params` object that was not a `Params`. This probably " "indicates malformed parameters in a configuration file, where something that " "should have been a dictionary was actually a list, or something else. " f"This happened when constructing an object of type {cls}." ) registered_subclasses = Registrable._registry.get(cls) if is_base_registrable(cls) and registered_subclasses is None: # NOTE(mattg): There are some potential corner cases in this logic if you have nested # Registrable types. We don't currently have any of those, but if we ever get them, # adding some logic to check `constructor_to_call` should solve the issue. Not # bothering to add that unnecessary complexity for now. raise ConfigurationError( "Tried to construct an abstract Registrable base class that has no registered " "concrete types. This might mean that you need to use --include-package to get " "your concrete classes actually registered." ) if registered_subclasses is not None and not constructor_to_call: # We know `cls` inherits from Registrable, so we'll use a cast to make mypy happy. as_registrable = cast(Type[Registrable], cls) default_to_first_choice = as_registrable.default_implementation is not None choice = params.pop_choice( "type", choices=as_registrable.list_available(), default_to_first_choice=default_to_first_choice, ) subclass, constructor_name = as_registrable.resolve_class_name(choice) # See the docstring for an explanation of what's going on here. if not constructor_name: constructor_to_inspect = subclass.__init__ constructor_to_call = subclass # type: ignore else: constructor_to_inspect = getattr(subclass, constructor_name) constructor_to_call = constructor_to_inspect if hasattr(subclass, "from_params"): # We want to call subclass.from_params. extras = create_extras(subclass, extras) # mypy can't follow the typing redirection that we do, so we explicitly cast here. retyped_subclass = cast(Type[T], subclass) return retyped_subclass.from_params( params=params, constructor_to_call=constructor_to_call, constructor_to_inspect=constructor_to_inspect, **extras, ) else: # In some rare cases, we get a registered subclass that does _not_ have a # from_params method (this happens with Activations, for instance, where we # register pytorch modules directly). This is a bit of a hack to make those work, # instead of adding a `from_params` method for them somehow. We just trust that # you've done the right thing in passing your parameters, and nothing else needs to # be recursively constructed. return subclass(**params) # type: ignore else: # This is not a base class, so convert our params and extras into a dict of kwargs. # See the docstring for an explanation of what's going on here. if not constructor_to_inspect: constructor_to_inspect = cls.__init__ if not constructor_to_call: constructor_to_call = cls if constructor_to_inspect == object.__init__: # This class does not have an explicit constructor, so don't give it any kwargs. # Without this logic, create_kwargs will look at object.__init__ and see that # it takes *args and **kwargs and look for those. kwargs: Dict[str, Any] = {} params.assert_empty(cls.__name__) else: # This class has a constructor, so create kwargs for it. kwargs = create_kwargs(constructor_to_inspect, cls, params, **extras) return constructor_to_call(**kwargs) # type: ignore
def from_params( cls: Type[T], params: Params, constructor_to_call: Callable[..., T] = None, constructor_to_inspect: Callable[..., T] = None, **extras, ) -> T: """ This is the automatic implementation of `from_params`. Any class that subclasses `FromParams` (or `Registrable`, which itself subclasses `FromParams`) gets this implementation for free. If you want your class to be instantiated from params in the "obvious" way -- pop off parameters and hand them to your constructor with the same names -- this provides that functionality. If you need more complex logic in your from `from_params` method, you'll have to implement your own method that overrides this one. The `constructor_to_call` and `constructor_to_inspect` arguments deal with a bit of redirection that we do. We allow you to register particular `@classmethods` on a class as the constructor to use for a registered name. This lets you, e.g., have a single `Vocabulary` class that can be constructed in two different ways, with different names registered to each constructor. In order to handle this, we need to know not just the class we're trying to construct (`cls`), but also what method we should inspect to find its arguments (`constructor_to_inspect`), and what method to call when we're done constructing arguments (`constructor_to_call`). These two methods are the same when you've used a `@classmethod` as your constructor, but they are `different` when you use the default constructor (because you inspect `__init__`, but call `cls()`). """ from allennlp.common.registrable import ( Registrable, ) # import here to avoid circular imports logger.debug( f"instantiating class {cls} from params {getattr(params, 'params', params)} " f"and extras {set(extras.keys())}" ) if params is None: return None if isinstance(params, str): params = Params({"type": params}) if not isinstance(params, Params): raise ConfigurationError( "from_params was passed a `params` object that was not a `Params`. This probably " "indicates malformed parameters in a configuration file, where something that " "should have been a dictionary was actually a list, or something else. " f"This happened when constructing an object of type {cls}." ) registered_subclasses = Registrable._registry.get(cls) if is_base_registrable(cls) and registered_subclasses is None: # NOTE(mattg): There are some potential corner cases in this logic if you have nested # Registrable types. We don't currently have any of those, but if we ever get them, # adding some logic to check `constructor_to_call` should solve the issue. Not # bothering to add that unnecessary complexity for now. raise ConfigurationError( "Tried to construct an abstract Registrable base class that has no registered " "concrete types. This might mean that you need to use --include-package to get " "your concrete classes actually registered." ) if registered_subclasses is not None and not constructor_to_call: # We know `cls` inherits from Registrable, so we'll use a cast to make mypy happy. as_registrable = cast(Type[Registrable], cls) default_to_first_choice = as_registrable.default_implementation is not None choice = params.pop_choice( "type", choices=as_registrable.list_available(), default_to_first_choice=default_to_first_choice, ) subclass, constructor_name = as_registrable.resolve_class_name(choice) # See the docstring for an explanation of what's going on here. if not constructor_name: constructor_to_inspect = subclass.__init__ constructor_to_call = subclass # type: ignore else: constructor_to_inspect = getattr(subclass, constructor_name) constructor_to_call = constructor_to_inspect if hasattr(subclass, "from_params"): # We want to call subclass.from_params. extras = create_extras(subclass, extras) # mypy can't follow the typing redirection that we do, so we explicitly cast here. retyped_subclass = cast(Type[T], subclass) return retyped_subclass.from_params( params=params, constructor_to_call=constructor_to_call, constructor_to_inspect=constructor_to_inspect, **extras, ) else: # In some rare cases, we get a registered subclass that does _not_ have a # from_params method (this happens with Activations, for instance, where we # register pytorch modules directly). This is a bit of a hack to make those work, # instead of adding a `from_params` method for them somehow. We just trust that # you've done the right thing in passing your parameters, and nothing else needs to # be recursively constructed. extras = create_extras(subclass, extras) constructor_args = {**params, **extras} return subclass(**constructor_args) # type: ignore else: # This is not a base class, so convert our params and extras into a dict of kwargs. # See the docstring for an explanation of what's going on here. if not constructor_to_inspect: constructor_to_inspect = cls.__init__ if not constructor_to_call: constructor_to_call = cls if constructor_to_inspect == object.__init__: # This class does not have an explicit constructor, so don't give it any kwargs. # Without this logic, create_kwargs will look at object.__init__ and see that # it takes *args and **kwargs and look for those. kwargs: Dict[str, Any] = {} params.assert_empty(cls.__name__) else: # This class has a constructor, so create kwargs for it. kwargs = create_kwargs(constructor_to_inspect, cls, params, **extras) return constructor_to_call(**kwargs) # type: ignore
https://github.com/allenai/allennlp/issues/4614
Traceback (most recent call last): File "tmp.py", line 10, in <module> Foo.from_params(Params({"a": 2, "b": "hi"})) File "/Users/evanw/AllenAI/allennlp/allennlp/common/from_params.py", line 610, in from_params kwargs = create_kwargs(constructor_to_inspect, cls, params, **extras) File "/Users/evanw/AllenAI/allennlp/allennlp/common/from_params.py", line 163, in create_kwargs parameters = infer_params(cls, constructor) File "/Users/evanw/AllenAI/allennlp/allennlp/common/from_params.py", line 140, in infer_params super_parameters = infer_params(super_class) File "/Users/evanw/AllenAI/allennlp/allennlp/common/from_params.py", line 139, in infer_params raise RuntimeError("found a kwargs parameter with no inspectable super class") RuntimeError: found a kwargs parameter with no inspectable super class
RuntimeError
def infer_params(cls: Type[T], constructor: Callable[..., T] = None) -> Dict[str, Any]: if constructor is None: constructor = cls.__init__ signature = inspect.signature(constructor) parameters = dict(signature.parameters) has_kwargs = False var_positional_key = None for param in parameters.values(): if param.kind == param.VAR_KEYWORD: has_kwargs = True elif param.kind == param.VAR_POSITIONAL: var_positional_key = param.name if var_positional_key: del parameters[var_positional_key] if not has_kwargs: return parameters # "mro" is "method resolution order". The first one is the current class, the next is the # first superclass, and so on. We take the first superclass we find that inherits from # FromParams. super_class = None for super_class_candidate in cls.mro()[1:]: if issubclass(super_class_candidate, FromParams): super_class = super_class_candidate break if super_class: super_parameters = infer_params(super_class) else: super_parameters = {} return { **super_parameters, **parameters, } # Subclass parameters overwrite superclass ones
def infer_params(cls: Type[T], constructor: Callable[..., T] = None) -> Dict[str, Any]: if cls == FromParams: return {} if constructor is None: constructor = cls.__init__ signature = inspect.signature(constructor) parameters = dict(signature.parameters) has_kwargs = False for param in parameters.values(): if param.kind == param.VAR_KEYWORD: has_kwargs = True if not has_kwargs: return parameters # "mro" is "method resolution order". The first one is the current class, the next is the # first superclass, and so on. We take the first superclass we find that inherits from # FromParams. super_class = None for super_class_candidate in cls.mro()[1:]: if issubclass(super_class_candidate, FromParams): super_class = super_class_candidate break if super_class: super_parameters = infer_params(super_class) else: super_parameters = {} return { **super_parameters, **parameters, } # Subclass parameters overwrite superclass ones
https://github.com/allenai/allennlp/issues/4614
Traceback (most recent call last): File "tmp.py", line 10, in <module> Foo.from_params(Params({"a": 2, "b": "hi"})) File "/Users/evanw/AllenAI/allennlp/allennlp/common/from_params.py", line 610, in from_params kwargs = create_kwargs(constructor_to_inspect, cls, params, **extras) File "/Users/evanw/AllenAI/allennlp/allennlp/common/from_params.py", line 163, in create_kwargs parameters = infer_params(cls, constructor) File "/Users/evanw/AllenAI/allennlp/allennlp/common/from_params.py", line 140, in infer_params super_parameters = infer_params(super_class) File "/Users/evanw/AllenAI/allennlp/allennlp/common/from_params.py", line 139, in infer_params raise RuntimeError("found a kwargs parameter with no inspectable super class") RuntimeError: found a kwargs parameter with no inspectable super class
RuntimeError
def __call__(self, tensor: torch.Tensor, parameter_name: str, **kwargs) -> None: # type: ignore # Select the new parameter name if it's being overridden if parameter_name in self.parameter_name_overrides: parameter_name = self.parameter_name_overrides[parameter_name] # If the size of the source and destination tensors are not the # same, then we need to raise an error source_weights = self.weights[parameter_name] if tensor.data.size() != source_weights.size(): raise ConfigurationError( "Incompatible sizes found for parameter %s. " "Found %s and %s" % (parameter_name, tensor.data.size(), source_weights.size()) ) # Copy the parameters from the source to the destination tensor.data.copy_(source_weights.data)
def __call__(self, tensor: torch.Tensor, parameter_name: str, **kwargs) -> None: # type: ignore # Select the new parameter name if it's being overridden if parameter_name in self.parameter_name_overrides: parameter_name = self.parameter_name_overrides[parameter_name] # If the size of the source and destination tensors are not the # same, then we need to raise an error source_weights = self.weights[parameter_name] if tensor.data.size() != source_weights.size(): raise ConfigurationError( "Incompatible sizes found for parameter %s. " "Found %s and %s" % (parameter_name, tensor.data.size(), source_weights.size()) ) # Copy the parameters from the source to the destination tensor.data[:] = source_weights[:]
https://github.com/allenai/allennlp/issues/4427
Traceback (most recent call last): File "test.py", line 27, in <module> applicator(net) File "/Users/reiyw/.ghq/ghq/github.com/allenai/allennlp/allennlp/nn/initializers.py", line 482, in __call__ initializer(parameter, parameter_name=name) File "/Users/reiyw/.ghq/ghq/github.com/allenai/allennlp/allennlp/nn/initializers.py", line 406, in __call__ tensor.data[:] = source_weights[:] IndexError: slice() cannot be applied to a 0-dim tensor.
IndexError
def from_path( cls, archive_path: str, predictor_name: str = None, cuda_device: int = -1, dataset_reader_to_load: str = "validation", frozen: bool = True, import_plugins: bool = True, ) -> "Predictor": """ Instantiate a `Predictor` from an archive path. If you need more detailed configuration options, such as overrides, please use `from_archive`. # Parameters archive_path : `str` The path to the archive. predictor_name : `str`, optional (default=`None`) Name that the predictor is registered as, or None to use the predictor associated with the model. cuda_device : `int`, optional (default=`-1`) If `cuda_device` is >= 0, the model will be loaded onto the corresponding GPU. Otherwise it will be loaded onto the CPU. dataset_reader_to_load : `str`, optional (default=`"validation"`) Which dataset reader to load from the archive, either "train" or "validation". frozen : `bool`, optional (default=`True`) If we should call `model.eval()` when building the predictor. import_plugins : `bool`, optional (default=`True`) If `True`, we attempt to import plugins before loading the predictor. This comes with additional overhead, but means you don't need to explicitly import the modules that your predictor depends on as long as those modules can be found by `allennlp.common.plugins.import_plugins()`. # Returns `Predictor` A Predictor instance. """ if import_plugins: plugins.import_plugins() return Predictor.from_archive( load_archive(archive_path, cuda_device=cuda_device), predictor_name, dataset_reader_to_load=dataset_reader_to_load, frozen=frozen, )
def from_path( cls, archive_path: str, predictor_name: str = None, cuda_device: int = -1, dataset_reader_to_load: str = "validation", frozen: bool = True, ) -> "Predictor": """ Instantiate a `Predictor` from an archive path. If you need more detailed configuration options, such as overrides, please use `from_archive`. # Parameters archive_path : `str` The path to the archive. predictor_name : `str`, optional (default=`None`) Name that the predictor is registered as, or None to use the predictor associated with the model. cuda_device : `int`, optional (default=`-1`) If `cuda_device` is >= 0, the model will be loaded onto the corresponding GPU. Otherwise it will be loaded onto the CPU. dataset_reader_to_load : `str`, optional (default=`"validation"`) Which dataset reader to load from the archive, either "train" or "validation". frozen : `bool`, optional (default=`True`) If we should call `model.eval()` when building the predictor. # Returns `Predictor` A Predictor instance. """ return Predictor.from_archive( load_archive(archive_path, cuda_device=cuda_device), predictor_name, dataset_reader_to_load=dataset_reader_to_load, frozen=frozen, )
https://github.com/allenai/allennlp/issues/4319
--------------------------------------------------------------------------- --------------------------------------------------------------------------- ConfigurationError Traceback (most recent call last) <ipython-input-56-91de5da48e5e> in <module>() 10 from allennlp.predictors.predictor import Predictor 11 get_ipython().system('pip install swifter') ---> 12 predictor = Predictor.from_path("/content/allenepi/model.tar.gz") 13 labels_dict = predictor._model.vocab.get_index_to_token_vocabulary('labels') 14 3 frames /usr/local/lib/python3.6/dist-packages/allennlp/predictors/predictor.py in from_path(cls, archive_path, predictor_name, cuda_device, dataset_reader_to_load, frozen) 257 predictor_name, 258 dataset_reader_to_load=dataset_reader_to_load, --> 259 frozen=frozen, 260 ) 261 /usr/local/lib/python3.6/dist-packages/allennlp/predictors/predictor.py in from_archive(cls, archive, predictor_name, dataset_reader_to_load, frozen) 292 else: 293 dataset_reader_params = config["dataset_reader"] --> 294 dataset_reader = DatasetReader.from_params(dataset_reader_params) 295 296 model = archive.model /usr/local/lib/python3.6/dist-packages/allennlp/common/from_params.py in from_params(cls, params, constructor_to_call, constructor_to_inspect, **extras) 558 "type", 559 choices=as_registrable.list_available(), --> 560 default_to_first_choice=default_to_first_choice, 561 ) 562 subclass, constructor_name = as_registrable.resolve_class_name(choice) /usr/local/lib/python3.6/dist-packages/allennlp/common/params.py in pop_choice(self, key, choices, default_to_first_choice, allow_class_names) 349 """{"model": "my_module.models.MyModel"} to have it imported automatically.""" 350 ) --> 351 raise ConfigurationError(message) 352 return value 353 ConfigurationError: snli not in acceptable choices for dataset_reader.type: ['conll2003', 'interleaving', 'sequence_tagging', 'sharded', 'babi', 'text_classification_json']. You should either use the --include-package flag to make sure the correct module is loaded, or use a fully qualified class name in your config file like {"model": "my_module.models.MyModel"} to have it imported automatically.```
ConfigurationError
def tokens_to_indices( self, tokens: List[Token], vocabulary: Vocabulary ) -> IndexedTokenList: self._matched_indexer._add_encoding_to_vocabulary_if_needed(vocabulary) wordpieces, offsets = self._allennlp_tokenizer.intra_word_tokenize( [t.text for t in tokens] ) # For tokens that don't correspond to any word pieces, we put (-1, -1) into the offsets. # That results in the embedding for the token to be all zeros. offsets = [x if x is not None else (-1, -1) for x in offsets] output: IndexedTokenList = { "token_ids": [t.text_id for t in wordpieces], "mask": [True] * len(tokens), # for original tokens (i.e. word-level) "type_ids": [t.type_id for t in wordpieces], "offsets": offsets, "wordpiece_mask": [True] * len(wordpieces), # for wordpieces (i.e. subword-level) } return self._matched_indexer._postprocess_output(output)
def tokens_to_indices( self, tokens: List[Token], vocabulary: Vocabulary ) -> IndexedTokenList: self._matched_indexer._add_encoding_to_vocabulary_if_needed(vocabulary) wordpieces, offsets = self._allennlp_tokenizer.intra_word_tokenize( [t.text for t in tokens] ) output: IndexedTokenList = { "token_ids": [t.text_id for t in wordpieces], "mask": [True] * len(tokens), # for original tokens (i.e. word-level) "type_ids": [t.type_id for t in wordpieces], "offsets": offsets, "wordpiece_mask": [True] * len(wordpieces), # for wordpieces (i.e. subword-level) } return self._matched_indexer._postprocess_output(output)
https://github.com/allenai/allennlp/issues/4281
Traceback (most recent call last): File "/home/arthur/question-generation/models/sg_dqg.py", line 156, in <module> preprocess(args.ds) File "/home/arthur/question-generation/models/sg_dqg.py", line 124, in preprocess coreferences = coreference_resolution(evidences_list) File "/home/arthur/question-generation/models/sg_dqg.py", line 74, in coreference_resolution document="Besides its prominence in sports, Notre Dame is also a large, four-year, highly residential research University, and is consistently ranked among the top twenty universities in the United States and as a major global university." File "/home/arthur/anaconda3/envs/tensorflow_env/lib/python3.6/site-packages/allennlp_models/coref/coref_predictor.py", line 65, in predict return self.predict_json({"document": document}) File "/home/arthur/anaconda3/envs/tensorflow_env/lib/python3.6/site-packages/allennlp/predictors/predictor.py", line 48, in predict_json return self.predict_instance(instance) File "/home/arthur/anaconda3/envs/tensorflow_env/lib/python3.6/site-packages/allennlp/predictors/predictor.py", line 171, in predict_instance outputs = self._model.forward_on_instance(instance) File "/home/arthur/anaconda3/envs/tensorflow_env/lib/python3.6/site-packages/allennlp/models/model.py", line 142, in forward_on_instance return self.forward_on_instances([instance])[0] File "/home/arthur/anaconda3/envs/tensorflow_env/lib/python3.6/site-packages/allennlp/models/model.py", line 167, in forward_on_instances model_input = util.move_to_device(dataset.as_tensor_dict(), cuda_device) File "/home/arthur/anaconda3/envs/tensorflow_env/lib/python3.6/site-packages/allennlp/data/batch.py", line 139, in as_tensor_dict for field, tensors in instance.as_tensor_dict(lengths_to_use).items(): File "/home/arthur/anaconda3/envs/tensorflow_env/lib/python3.6/site-packages/allennlp/data/instance.py", line 99, in as_tensor_dict tensors[field_name] = field.as_tensor(padding_lengths[field_name]) File "/home/arthur/anaconda3/envs/tensorflow_env/lib/python3.6/site-packages/allennlp/data/fields/text_field.py", line 103, in as_tensor self._indexed_tokens[indexer_name], indexer_lengths[indexer_name] File "/home/arthur/anaconda3/envs/tensorflow_env/lib/python3.6/site-packages/allennlp/data/token_indexers/pretrained_transformer_mismatched_indexer.py", line 96, in as_padded_tensor_dict offsets_tokens, offsets_padding_lengths, default_value=lambda: (0, 0) TypeError: not a sequence
TypeError
def forward( self, token_ids: torch.LongTensor, mask: torch.BoolTensor, offsets: torch.LongTensor, wordpiece_mask: torch.BoolTensor, type_ids: Optional[torch.LongTensor] = None, segment_concat_mask: Optional[torch.BoolTensor] = None, ) -> torch.Tensor: # type: ignore """ # Parameters token_ids: `torch.LongTensor` Shape: [batch_size, num_wordpieces] (for exception see `PretrainedTransformerEmbedder`). mask: `torch.BoolTensor` Shape: [batch_size, num_orig_tokens]. offsets: `torch.LongTensor` Shape: [batch_size, num_orig_tokens, 2]. Maps indices for the original tokens, i.e. those given as input to the indexer, to a span in token_ids. `token_ids[i][offsets[i][j][0]:offsets[i][j][1] + 1]` corresponds to the original j-th token from the i-th batch. wordpiece_mask: `torch.BoolTensor` Shape: [batch_size, num_wordpieces]. type_ids: `Optional[torch.LongTensor]` Shape: [batch_size, num_wordpieces]. segment_concat_mask: `Optional[torch.BoolTensor]` See `PretrainedTransformerEmbedder`. # Returns `torch.Tensor` Shape: [batch_size, num_orig_tokens, embedding_size]. """ # Shape: [batch_size, num_wordpieces, embedding_size]. embeddings = self._matched_embedder( token_ids, wordpiece_mask, type_ids=type_ids, segment_concat_mask=segment_concat_mask, ) # span_embeddings: (batch_size, num_orig_tokens, max_span_length, embedding_size) # span_mask: (batch_size, num_orig_tokens, max_span_length) span_embeddings, span_mask = util.batched_span_select( embeddings.contiguous(), offsets ) span_mask = span_mask.unsqueeze(-1) span_embeddings *= span_mask # zero out paddings span_embeddings_sum = span_embeddings.sum(2) span_embeddings_len = span_mask.sum(2) # Shape: (batch_size, num_orig_tokens, embedding_size) orig_embeddings = span_embeddings_sum / span_embeddings_len # All the places where the span length is zero, write in zeros. orig_embeddings[(span_embeddings_len == 0).expand(orig_embeddings.shape)] = 0 return orig_embeddings
def forward( self, token_ids: torch.LongTensor, mask: torch.BoolTensor, offsets: torch.LongTensor, wordpiece_mask: torch.BoolTensor, type_ids: Optional[torch.LongTensor] = None, segment_concat_mask: Optional[torch.BoolTensor] = None, ) -> torch.Tensor: # type: ignore """ # Parameters token_ids: `torch.LongTensor` Shape: [batch_size, num_wordpieces] (for exception see `PretrainedTransformerEmbedder`). mask: `torch.BoolTensor` Shape: [batch_size, num_orig_tokens]. offsets: `torch.LongTensor` Shape: [batch_size, num_orig_tokens, 2]. Maps indices for the original tokens, i.e. those given as input to the indexer, to a span in token_ids. `token_ids[i][offsets[i][j][0]:offsets[i][j][1] + 1]` corresponds to the original j-th token from the i-th batch. wordpiece_mask: `torch.BoolTensor` Shape: [batch_size, num_wordpieces]. type_ids: `Optional[torch.LongTensor]` Shape: [batch_size, num_wordpieces]. segment_concat_mask: `Optional[torch.BoolTensor]` See `PretrainedTransformerEmbedder`. # Returns `torch.Tensor` Shape: [batch_size, num_orig_tokens, embedding_size]. """ # Shape: [batch_size, num_wordpieces, embedding_size]. embeddings = self._matched_embedder( token_ids, wordpiece_mask, type_ids=type_ids, segment_concat_mask=segment_concat_mask, ) # span_embeddings: (batch_size, num_orig_tokens, max_span_length, embedding_size) # span_mask: (batch_size, num_orig_tokens, max_span_length) span_embeddings, span_mask = util.batched_span_select( embeddings.contiguous(), offsets ) span_mask = span_mask.unsqueeze(-1) span_embeddings *= span_mask # zero out paddings span_embeddings_sum = span_embeddings.sum(2) span_embeddings_len = span_mask.sum(2) # Shape: (batch_size, num_orig_tokens, embedding_size) orig_embeddings = span_embeddings_sum / span_embeddings_len return orig_embeddings
https://github.com/allenai/allennlp/issues/4281
Traceback (most recent call last): File "/home/arthur/question-generation/models/sg_dqg.py", line 156, in <module> preprocess(args.ds) File "/home/arthur/question-generation/models/sg_dqg.py", line 124, in preprocess coreferences = coreference_resolution(evidences_list) File "/home/arthur/question-generation/models/sg_dqg.py", line 74, in coreference_resolution document="Besides its prominence in sports, Notre Dame is also a large, four-year, highly residential research University, and is consistently ranked among the top twenty universities in the United States and as a major global university." File "/home/arthur/anaconda3/envs/tensorflow_env/lib/python3.6/site-packages/allennlp_models/coref/coref_predictor.py", line 65, in predict return self.predict_json({"document": document}) File "/home/arthur/anaconda3/envs/tensorflow_env/lib/python3.6/site-packages/allennlp/predictors/predictor.py", line 48, in predict_json return self.predict_instance(instance) File "/home/arthur/anaconda3/envs/tensorflow_env/lib/python3.6/site-packages/allennlp/predictors/predictor.py", line 171, in predict_instance outputs = self._model.forward_on_instance(instance) File "/home/arthur/anaconda3/envs/tensorflow_env/lib/python3.6/site-packages/allennlp/models/model.py", line 142, in forward_on_instance return self.forward_on_instances([instance])[0] File "/home/arthur/anaconda3/envs/tensorflow_env/lib/python3.6/site-packages/allennlp/models/model.py", line 167, in forward_on_instances model_input = util.move_to_device(dataset.as_tensor_dict(), cuda_device) File "/home/arthur/anaconda3/envs/tensorflow_env/lib/python3.6/site-packages/allennlp/data/batch.py", line 139, in as_tensor_dict for field, tensors in instance.as_tensor_dict(lengths_to_use).items(): File "/home/arthur/anaconda3/envs/tensorflow_env/lib/python3.6/site-packages/allennlp/data/instance.py", line 99, in as_tensor_dict tensors[field_name] = field.as_tensor(padding_lengths[field_name]) File "/home/arthur/anaconda3/envs/tensorflow_env/lib/python3.6/site-packages/allennlp/data/fields/text_field.py", line 103, in as_tensor self._indexed_tokens[indexer_name], indexer_lengths[indexer_name] File "/home/arthur/anaconda3/envs/tensorflow_env/lib/python3.6/site-packages/allennlp/data/token_indexers/pretrained_transformer_mismatched_indexer.py", line 96, in as_padded_tensor_dict offsets_tokens, offsets_padding_lengths, default_value=lambda: (0, 0) TypeError: not a sequence
TypeError
def get_posonlyargs(node: AnyFunctionDefAndLambda) -> List[ast.arg]: """ Function to get posonlyargs in all versions of python. This field was added in ``python3.8+``. And it was not present before. mypy also gives an error on this on older version of python:: error: "arguments" has no attribute "posonlyargs"; maybe "kwonlyargs"? """ return getattr(node.args, "posonlyargs", [])
def get_posonlyargs(node: AnyFunctionDefAndLambda) -> List[ast.arg]: """ Helper function to get posonlyargs in all version of python. This field was added in ``python3.8+``. And it was not present before. mypy also gives an error on this on older version of python:: error: "arguments" has no attribute "posonlyargs"; maybe "kwonlyargs"? """ return getattr(node.args, "posonlyargs", [])
https://github.com/wemake-services/wemake-python-styleguide/issues/1652
/Users/DBoger/PycharmProjects/project/.venv/bin/python -m flake8 project Traceback (most recent call last): File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/checker.py", line 154, in run visitor.run() File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/base.py", line 191, in run self.visit(self.tree) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/base.py", line 186, in visit return route_visit(self, tree) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/compat/routing.py", line 36, in route_visit return getattr( File "/Users/DBoger/.pyenv/versions/3.9.0b5/lib/python3.9/ast.py", line 408, in generic_visit self.visit(item) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/base.py", line 186, in visit return route_visit(self, tree) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/compat/routing.py", line 36, in route_visit return getattr( File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/ast/complexity/annotations.py", line 34, in visit_any_function self._check_function_annotations_complexity(node) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/ast/complexity/annotations.py", line 58, in _check_function_annotations_complexity self._check_annotations_complexity(node, annotations) File "/Users/DBoger/PycharmProjects/sellerly-profile/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/ast/complexity/annotations.py", line 67, in _check_annotations_complexity complexity = get_annotation_compexity(annotation) File "/Users/DBoger/PycharmProjects/sellerly-profile/.venv/lib/python3.9/site-packages/wemake_python_styleguide/logic/complexity/annotations.py", line 36, in get_annotation_compexity annotation_node.slice.value, # type: ignore AttributeError: 'Tuple' object has no attribute 'value'
AttributeError
def get_annotation_compexity(annotation_node: _Annotation) -> int: """ Recursevly counts complexity of annotation nodes. When annotations are written as strings, we additionally parse them to ``ast`` nodes. """ if isinstance(annotation_node, ast.Str): # try to parse string-wrapped annotations try: annotation_node = ( ast.parse( # type: ignore annotation_node.s, ) .body[0] .value ) except (SyntaxError, IndexError): return 1 if isinstance(annotation_node, ast.Subscript): return 1 + get_annotation_compexity(get_slice_expr(annotation_node)) elif isinstance(annotation_node, (ast.Tuple, ast.List)): return max( (get_annotation_compexity(node) for node in annotation_node.elts), default=1, ) return 1
def get_annotation_compexity(annotation_node: _Annotation) -> int: """ Recursevly counts complexity of annotation nodes. When annotations are written as strings, we additionally parse them to ``ast`` nodes. """ if isinstance(annotation_node, ast.Str): # try to parse string-wrapped annotations try: annotation_node = ( ast.parse( # type: ignore annotation_node.s, ) .body[0] .value ) except (SyntaxError, IndexError): return 1 if isinstance(annotation_node, ast.Subscript): return 1 + get_annotation_compexity( annotation_node.slice.value, # type: ignore ) elif isinstance(annotation_node, (ast.Tuple, ast.List)): return max( (get_annotation_compexity(node) for node in annotation_node.elts), default=1, ) return 1
https://github.com/wemake-services/wemake-python-styleguide/issues/1652
/Users/DBoger/PycharmProjects/project/.venv/bin/python -m flake8 project Traceback (most recent call last): File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/checker.py", line 154, in run visitor.run() File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/base.py", line 191, in run self.visit(self.tree) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/base.py", line 186, in visit return route_visit(self, tree) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/compat/routing.py", line 36, in route_visit return getattr( File "/Users/DBoger/.pyenv/versions/3.9.0b5/lib/python3.9/ast.py", line 408, in generic_visit self.visit(item) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/base.py", line 186, in visit return route_visit(self, tree) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/compat/routing.py", line 36, in route_visit return getattr( File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/ast/complexity/annotations.py", line 34, in visit_any_function self._check_function_annotations_complexity(node) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/ast/complexity/annotations.py", line 58, in _check_function_annotations_complexity self._check_annotations_complexity(node, annotations) File "/Users/DBoger/PycharmProjects/sellerly-profile/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/ast/complexity/annotations.py", line 67, in _check_annotations_complexity complexity = get_annotation_compexity(annotation) File "/Users/DBoger/PycharmProjects/sellerly-profile/.venv/lib/python3.9/site-packages/wemake_python_styleguide/logic/complexity/annotations.py", line 36, in get_annotation_compexity annotation_node.slice.value, # type: ignore AttributeError: 'Tuple' object has no attribute 'value'
AttributeError
def is_same_slice( iterable: str, target: str, node: ast.Subscript, ) -> bool: """Used to tell when slice is identical to some pair of name/index.""" return ( source.node_to_string(node.value) == iterable and source.node_to_string(get_slice_expr(node)) == target )
def is_same_slice( iterable: str, target: str, node: ast.Subscript, ) -> bool: """Used to tell when slice is identical to some pair of name/index.""" return ( source.node_to_string(node.value) == iterable and isinstance(node.slice, ast.Index) # mypy is unhappy and source.node_to_string(node.slice.value) == target )
https://github.com/wemake-services/wemake-python-styleguide/issues/1652
/Users/DBoger/PycharmProjects/project/.venv/bin/python -m flake8 project Traceback (most recent call last): File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/checker.py", line 154, in run visitor.run() File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/base.py", line 191, in run self.visit(self.tree) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/base.py", line 186, in visit return route_visit(self, tree) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/compat/routing.py", line 36, in route_visit return getattr( File "/Users/DBoger/.pyenv/versions/3.9.0b5/lib/python3.9/ast.py", line 408, in generic_visit self.visit(item) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/base.py", line 186, in visit return route_visit(self, tree) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/compat/routing.py", line 36, in route_visit return getattr( File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/ast/complexity/annotations.py", line 34, in visit_any_function self._check_function_annotations_complexity(node) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/ast/complexity/annotations.py", line 58, in _check_function_annotations_complexity self._check_annotations_complexity(node, annotations) File "/Users/DBoger/PycharmProjects/sellerly-profile/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/ast/complexity/annotations.py", line 67, in _check_annotations_complexity complexity = get_annotation_compexity(annotation) File "/Users/DBoger/PycharmProjects/sellerly-profile/.venv/lib/python3.9/site-packages/wemake_python_styleguide/logic/complexity/annotations.py", line 36, in get_annotation_compexity annotation_node.slice.value, # type: ignore AttributeError: 'Tuple' object has no attribute 'value'
AttributeError
def _is_valid_final_value(self, format_value: ast.AST) -> bool: # Variable lookup is okay and a single attribute is okay if isinstance(format_value, (ast.Name, ast.Attribute)): return True # Function call with empty arguments is okay elif isinstance(format_value, ast.Call) and not format_value.args: return True # Named lookup, Index lookup & Dict key is okay elif isinstance(format_value, ast.Subscript): return isinstance( get_slice_expr(format_value), self._valid_format_index, ) return False
def _is_valid_final_value(self, format_value: ast.AST) -> bool: # Variable lookup is okay and a single attribute is okay if isinstance(format_value, (ast.Name, ast.Attribute)): return True # Function call with empty arguments is okay elif isinstance(format_value, ast.Call) and not format_value.args: return True # Named lookup, Index lookup & Dict key is okay elif isinstance(format_value, ast.Subscript): if isinstance(format_value.slice, ast.Index): return isinstance( format_value.slice.value, self._valid_format_index, ) return False
https://github.com/wemake-services/wemake-python-styleguide/issues/1652
/Users/DBoger/PycharmProjects/project/.venv/bin/python -m flake8 project Traceback (most recent call last): File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/checker.py", line 154, in run visitor.run() File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/base.py", line 191, in run self.visit(self.tree) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/base.py", line 186, in visit return route_visit(self, tree) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/compat/routing.py", line 36, in route_visit return getattr( File "/Users/DBoger/.pyenv/versions/3.9.0b5/lib/python3.9/ast.py", line 408, in generic_visit self.visit(item) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/base.py", line 186, in visit return route_visit(self, tree) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/compat/routing.py", line 36, in route_visit return getattr( File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/ast/complexity/annotations.py", line 34, in visit_any_function self._check_function_annotations_complexity(node) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/ast/complexity/annotations.py", line 58, in _check_function_annotations_complexity self._check_annotations_complexity(node, annotations) File "/Users/DBoger/PycharmProjects/sellerly-profile/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/ast/complexity/annotations.py", line 67, in _check_annotations_complexity complexity = get_annotation_compexity(annotation) File "/Users/DBoger/PycharmProjects/sellerly-profile/.venv/lib/python3.9/site-packages/wemake_python_styleguide/logic/complexity/annotations.py", line 36, in get_annotation_compexity annotation_node.slice.value, # type: ignore AttributeError: 'Tuple' object has no attribute 'value'
AttributeError
def _check_float_key(self, node: ast.Subscript) -> None: if self._is_float_key(get_slice_expr(node)): self.add_violation(best_practices.FloatKeyViolation(node))
def _check_float_key(self, node: ast.Subscript) -> None: is_float_key = isinstance(node.slice, ast.Index) and self._is_float_key(node.slice) if is_float_key: self.add_violation(best_practices.FloatKeyViolation(node))
https://github.com/wemake-services/wemake-python-styleguide/issues/1652
/Users/DBoger/PycharmProjects/project/.venv/bin/python -m flake8 project Traceback (most recent call last): File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/checker.py", line 154, in run visitor.run() File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/base.py", line 191, in run self.visit(self.tree) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/base.py", line 186, in visit return route_visit(self, tree) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/compat/routing.py", line 36, in route_visit return getattr( File "/Users/DBoger/.pyenv/versions/3.9.0b5/lib/python3.9/ast.py", line 408, in generic_visit self.visit(item) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/base.py", line 186, in visit return route_visit(self, tree) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/compat/routing.py", line 36, in route_visit return getattr( File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/ast/complexity/annotations.py", line 34, in visit_any_function self._check_function_annotations_complexity(node) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/ast/complexity/annotations.py", line 58, in _check_function_annotations_complexity self._check_annotations_complexity(node, annotations) File "/Users/DBoger/PycharmProjects/sellerly-profile/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/ast/complexity/annotations.py", line 67, in _check_annotations_complexity complexity = get_annotation_compexity(annotation) File "/Users/DBoger/PycharmProjects/sellerly-profile/.venv/lib/python3.9/site-packages/wemake_python_styleguide/logic/complexity/annotations.py", line 36, in get_annotation_compexity annotation_node.slice.value, # type: ignore AttributeError: 'Tuple' object has no attribute 'value'
AttributeError
def _check_len_call(self, node: ast.Subscript) -> None: node_slice = get_slice_expr(node) is_len_call = ( isinstance(node_slice, ast.BinOp) and isinstance(node_slice.op, ast.Sub) and self._is_wrong_len( node_slice, source.node_to_string(node.value), ) ) if is_len_call: self.add_violation( refactoring.ImplicitNegativeIndexViolation(node), )
def _check_len_call(self, node: ast.Subscript) -> None: is_len_call = ( isinstance(node.slice, ast.Index) and isinstance(node.slice.value, ast.BinOp) and isinstance(node.slice.value.op, ast.Sub) and self._is_wrong_len( node.slice.value, source.node_to_string(node.value), ) ) if is_len_call: self.add_violation( refactoring.ImplicitNegativeIndexViolation(node), )
https://github.com/wemake-services/wemake-python-styleguide/issues/1652
/Users/DBoger/PycharmProjects/project/.venv/bin/python -m flake8 project Traceback (most recent call last): File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/checker.py", line 154, in run visitor.run() File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/base.py", line 191, in run self.visit(self.tree) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/base.py", line 186, in visit return route_visit(self, tree) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/compat/routing.py", line 36, in route_visit return getattr( File "/Users/DBoger/.pyenv/versions/3.9.0b5/lib/python3.9/ast.py", line 408, in generic_visit self.visit(item) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/base.py", line 186, in visit return route_visit(self, tree) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/compat/routing.py", line 36, in route_visit return getattr( File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/ast/complexity/annotations.py", line 34, in visit_any_function self._check_function_annotations_complexity(node) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/ast/complexity/annotations.py", line 58, in _check_function_annotations_complexity self._check_annotations_complexity(node, annotations) File "/Users/DBoger/PycharmProjects/sellerly-profile/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/ast/complexity/annotations.py", line 67, in _check_annotations_complexity complexity = get_annotation_compexity(annotation) File "/Users/DBoger/PycharmProjects/sellerly-profile/.venv/lib/python3.9/site-packages/wemake_python_styleguide/logic/complexity/annotations.py", line 36, in get_annotation_compexity annotation_node.slice.value, # type: ignore AttributeError: 'Tuple' object has no attribute 'value'
AttributeError
def _is_float_key(self, node: ast.expr) -> bool: real_node = operators.unwrap_unary_node(node) return isinstance(real_node, ast.Num) and isinstance(real_node.n, float)
def _is_float_key(self, node: ast.Index) -> bool: real_node = operators.unwrap_unary_node(node.value) return isinstance(real_node, ast.Num) and isinstance(real_node.n, float)
https://github.com/wemake-services/wemake-python-styleguide/issues/1652
/Users/DBoger/PycharmProjects/project/.venv/bin/python -m flake8 project Traceback (most recent call last): File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/checker.py", line 154, in run visitor.run() File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/base.py", line 191, in run self.visit(self.tree) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/base.py", line 186, in visit return route_visit(self, tree) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/compat/routing.py", line 36, in route_visit return getattr( File "/Users/DBoger/.pyenv/versions/3.9.0b5/lib/python3.9/ast.py", line 408, in generic_visit self.visit(item) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/base.py", line 186, in visit return route_visit(self, tree) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/compat/routing.py", line 36, in route_visit return getattr( File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/ast/complexity/annotations.py", line 34, in visit_any_function self._check_function_annotations_complexity(node) File "/Users/DBoger/PycharmProjects/project/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/ast/complexity/annotations.py", line 58, in _check_function_annotations_complexity self._check_annotations_complexity(node, annotations) File "/Users/DBoger/PycharmProjects/sellerly-profile/.venv/lib/python3.9/site-packages/wemake_python_styleguide/visitors/ast/complexity/annotations.py", line 67, in _check_annotations_complexity complexity = get_annotation_compexity(annotation) File "/Users/DBoger/PycharmProjects/sellerly-profile/.venv/lib/python3.9/site-packages/wemake_python_styleguide/logic/complexity/annotations.py", line 36, in get_annotation_compexity annotation_node.slice.value, # type: ignore AttributeError: 'Tuple' object has no attribute 'value'
AttributeError
def show_source(self, error: Violation) -> str: """Called when ``--show-source`` option is provided.""" if not self._should_show_source(error): return "" formated_line = error.physical_line.lstrip() adjust = len(error.physical_line) - len(formated_line) code = _highlight( formated_line, self._lexer, self._formatter, ) return " {code} {pointer}^".format( code=code, pointer=" " * (error.column_number - 1 - adjust), )
def show_source(self, error: Violation) -> str: """Called when ``--show-source`` option is provided.""" if not self._should_show_source(error): return "" formated_line = error.physical_line.lstrip() adjust = len(error.physical_line) - len(formated_line) code = highlight( formated_line, self._lexer, self._formatter, ) return " {code} {pointer}^".format( code=code, pointer=" " * (error.column_number - 1 - adjust), )
https://github.com/wemake-services/wemake-python-styleguide/issues/794
multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/click/termui.py", line 372, in style bits.append('\033[%dm' % (_ansi_colors.index(fg) + 30)) ValueError: tuple.index(x): x not in tuple During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 121, in worker result = (True, func(*args, **kwds)) File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 44, in mapstar return list(map(*args)) File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 666, in _run_checks return checker.run_checks() File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 598, in run_checks self.run_ast_checks() File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 502, in run_ast_checks for (line_number, offset, text, check) in runner: File "/usr/local/lib/python3.7/site-packages/nitpick/plugin.py", line 58, in run yield from checker.check_exists() File "/usr/local/lib/python3.7/site-packages/nitpick/files/base.py", line 87, in check_exists yield from self.check_rules() File "/usr/local/lib/python3.7/site-packages/nitpick/files/setup_cfg.py", line 67, in check_rules yield from self.show_missing_keys(section, key, values) File "/usr/local/lib/python3.7/site-packages/nitpick/files/setup_cfg.py", line 106, in show_missing_keys yield self.flake8_error(4, ": section [{}] has some missing key/value pairs. Use this:".format(section), output) File "/usr/local/lib/python3.7/site-packages/nitpick/mixin.py", line 20, in flake8_error click.style("\n{}".format(suggestion.rstrip()), fg="bright_green") if suggestion else "" File "/usr/local/lib/python3.7/site-packages/click/termui.py", line 374, in style raise TypeError('Unknown color %r' % fg) TypeError: Unknown color 'bright_green' """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/local/bin/flake8", line 11, in <module> sys.exit(main()) File "/usr/local/lib/python3.7/site-packages/flake8/main/cli.py", line 18, in main app.run(argv) File "/usr/local/lib/python3.7/site-packages/flake8/main/application.py", line 393, in run self._run(argv) File "/usr/local/lib/python3.7/site-packages/flake8/main/application.py", line 381, in _run self.run_checks() File "/usr/local/lib/python3.7/site-packages/flake8/main/application.py", line 300, in run_checks self.file_checker_manager.run() File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 329, in run self.run_parallel() File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 293, in run_parallel for ret in pool_map: File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 354, in <genexpr> return (item for chunk in result for item in chunk) File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 748, in next raise value TypeError: Unknown color 'bright_green'
ValueError
def _check_useless_math_operator( self, op: ast.operator, left: Optional[ast.AST], right: Optional[ast.AST] = None, ) -> None: if isinstance(left, ast.Num) and left.n in self._left_special_cases: if right and isinstance(op, self._left_special_cases[left.n]): left = None non_negative_numbers = self._get_non_negative_nodes(left, right) for number in non_negative_numbers: forbidden = self._meaningless_operations.get(number.n, None) if forbidden and isinstance(op, forbidden): self.add_violation( consistency.MeaninglessNumberOperationViolation(number), )
def _check_useless_math_operator( self, op: ast.operator, left: ast.AST, right: Optional[ast.AST] = None, ) -> None: if isinstance(left, ast.Num) and right: if left.n == 1: left = None non_negative_numbers = self._get_non_negative_nodes(left, right) for number in non_negative_numbers: forbidden = self._meaningless_operations.get(number.n, None) if forbidden and isinstance(op, forbidden): self.add_violation( consistency.MeaninglessNumberOperationViolation(number), )
https://github.com/wemake-services/wemake-python-styleguide/issues/794
multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/click/termui.py", line 372, in style bits.append('\033[%dm' % (_ansi_colors.index(fg) + 30)) ValueError: tuple.index(x): x not in tuple During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 121, in worker result = (True, func(*args, **kwds)) File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 44, in mapstar return list(map(*args)) File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 666, in _run_checks return checker.run_checks() File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 598, in run_checks self.run_ast_checks() File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 502, in run_ast_checks for (line_number, offset, text, check) in runner: File "/usr/local/lib/python3.7/site-packages/nitpick/plugin.py", line 58, in run yield from checker.check_exists() File "/usr/local/lib/python3.7/site-packages/nitpick/files/base.py", line 87, in check_exists yield from self.check_rules() File "/usr/local/lib/python3.7/site-packages/nitpick/files/setup_cfg.py", line 67, in check_rules yield from self.show_missing_keys(section, key, values) File "/usr/local/lib/python3.7/site-packages/nitpick/files/setup_cfg.py", line 106, in show_missing_keys yield self.flake8_error(4, ": section [{}] has some missing key/value pairs. Use this:".format(section), output) File "/usr/local/lib/python3.7/site-packages/nitpick/mixin.py", line 20, in flake8_error click.style("\n{}".format(suggestion.rstrip()), fg="bright_green") if suggestion else "" File "/usr/local/lib/python3.7/site-packages/click/termui.py", line 374, in style raise TypeError('Unknown color %r' % fg) TypeError: Unknown color 'bright_green' """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/local/bin/flake8", line 11, in <module> sys.exit(main()) File "/usr/local/lib/python3.7/site-packages/flake8/main/cli.py", line 18, in main app.run(argv) File "/usr/local/lib/python3.7/site-packages/flake8/main/application.py", line 393, in run self._run(argv) File "/usr/local/lib/python3.7/site-packages/flake8/main/application.py", line 381, in _run self.run_checks() File "/usr/local/lib/python3.7/site-packages/flake8/main/application.py", line 300, in run_checks self.file_checker_manager.run() File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 329, in run self.run_parallel() File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 293, in run_parallel for ret in pool_map: File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 354, in <genexpr> return (item for chunk in result for item in chunk) File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 748, in next raise value TypeError: Unknown color 'bright_green'
ValueError
def _get_non_negative_nodes( self, left: Optional[ast.AST], right: Optional[ast.AST] = None, ): non_negative_numbers = [] for node in filter(None, (left, right)): real_node = unwrap_unary_node(node) if not isinstance(real_node, ast.Num): continue if real_node.n not in self._meaningless_operations: continue if real_node.n == 1 and walk.is_contained(node, ast.USub): continue non_negative_numbers.append(real_node) return non_negative_numbers
def _get_non_negative_nodes( self, left: ast.AST, right: Optional[ast.AST] = None, ): non_negative_numbers = [] for node in filter(None, (left, right)): real_node = unwrap_unary_node(node) if not isinstance(real_node, ast.Num): continue if real_node.n not in self._meaningless_operations: continue if real_node.n == 1 and walk.is_contained(node, ast.USub): continue non_negative_numbers.append(real_node) return non_negative_numbers
https://github.com/wemake-services/wemake-python-styleguide/issues/794
multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/click/termui.py", line 372, in style bits.append('\033[%dm' % (_ansi_colors.index(fg) + 30)) ValueError: tuple.index(x): x not in tuple During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 121, in worker result = (True, func(*args, **kwds)) File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 44, in mapstar return list(map(*args)) File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 666, in _run_checks return checker.run_checks() File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 598, in run_checks self.run_ast_checks() File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 502, in run_ast_checks for (line_number, offset, text, check) in runner: File "/usr/local/lib/python3.7/site-packages/nitpick/plugin.py", line 58, in run yield from checker.check_exists() File "/usr/local/lib/python3.7/site-packages/nitpick/files/base.py", line 87, in check_exists yield from self.check_rules() File "/usr/local/lib/python3.7/site-packages/nitpick/files/setup_cfg.py", line 67, in check_rules yield from self.show_missing_keys(section, key, values) File "/usr/local/lib/python3.7/site-packages/nitpick/files/setup_cfg.py", line 106, in show_missing_keys yield self.flake8_error(4, ": section [{}] has some missing key/value pairs. Use this:".format(section), output) File "/usr/local/lib/python3.7/site-packages/nitpick/mixin.py", line 20, in flake8_error click.style("\n{}".format(suggestion.rstrip()), fg="bright_green") if suggestion else "" File "/usr/local/lib/python3.7/site-packages/click/termui.py", line 374, in style raise TypeError('Unknown color %r' % fg) TypeError: Unknown color 'bright_green' """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/local/bin/flake8", line 11, in <module> sys.exit(main()) File "/usr/local/lib/python3.7/site-packages/flake8/main/cli.py", line 18, in main app.run(argv) File "/usr/local/lib/python3.7/site-packages/flake8/main/application.py", line 393, in run self._run(argv) File "/usr/local/lib/python3.7/site-packages/flake8/main/application.py", line 381, in _run self.run_checks() File "/usr/local/lib/python3.7/site-packages/flake8/main/application.py", line 300, in run_checks self.file_checker_manager.run() File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 329, in run self.run_parallel() File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 293, in run_parallel for ret in pool_map: File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 354, in <genexpr> return (item for chunk in result for item in chunk) File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 748, in next raise value TypeError: Unknown color 'bright_green'
ValueError
def visit_collection(self, node: AnyCollection) -> None: """Checks how collection items indentation.""" if isinstance(node, ast.Dict): elements = normalize_dict_elements(node) else: elements = node.elts self._check_indentation(node, elements, extra_lines=1) self.generic_visit(node)
def visit_collection(self, node: AnyCollection) -> None: """Checks how collection items indentation.""" elements = node.keys if isinstance(node, ast.Dict) else node.elts self._check_indentation(node, elements, extra_lines=1) self.generic_visit(node)
https://github.com/wemake-services/wemake-python-styleguide/issues/450
multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/lib/python3.7/multiprocessing/pool.py", line 121, in worker result = (True, func(*args, **kwds)) File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/flake8/checker.py", line 682, in _run_checks return checker.run_checks() File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/flake8/checker.py", line 612, in run_checks self.run_ast_checks() File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/flake8/checker.py", line 520, in run_ast_checks for (line_number, offset, text, check) in runner: File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/wemake_python_styleguide/checker.py", line 178, in run yield from self._run_checks(self.visitors) File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/wemake_python_styleguide/checker.py", line 166, in _run_checks visitor.run() File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/wemake_python_styleguide/visitors/base.py", line 140, in run self.visit(self.tree) File "/usr/lib/python3.7/ast.py", line 262, in visit return visitor(node) File "/usr/lib/python3.7/ast.py", line 270, in generic_visit self.visit(item) File "/usr/lib/python3.7/ast.py", line 262, in visit return visitor(node) File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/wemake_python_styleguide/visitors/ast/statements.py", line 237, in visit_ClassDef self.generic_visit(node) File "/usr/lib/python3.7/ast.py", line 270, in generic_visit self.visit(item) File "/usr/lib/python3.7/ast.py", line 262, in visit return visitor(node) File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/wemake_python_styleguide/visitors/ast/statements.py", line 231, in visit_any_function self.generic_visit(node) File "/usr/lib/python3.7/ast.py", line 270, in generic_visit self.visit(item) File "/usr/lib/python3.7/ast.py", line 262, in visit return visitor(node) File "/usr/lib/python3.7/ast.py", line 272, in generic_visit self.visit(value) File "/usr/lib/python3.7/ast.py", line 262, in visit return visitor(node) File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/wemake_python_styleguide/visitors/ast/statements.py", line 219, in visit_collection self._check_indentation(node, elements, extra_lines=1) File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/wemake_python_styleguide/visitors/ast/statements.py", line 206, in _check_indentation extra_lines, File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/wemake_python_styleguide/visitors/ast/statements.py", line 171, in _check_first_element if statement.lineno == node.lineno and not extra_lines: AttributeError: 'NoneType' object has no attribute 'lineno' """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/bin/flake8", line 11, in <module> sys.exit(main()) File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/flake8/main/cli.py", line 16, in main app.run(argv) File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/flake8/main/application.py", line 412, in run self._run(argv) File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/flake8/main/application.py", line 400, in _run self.run_checks() File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/flake8/main/application.py", line 318, in run_checks self.file_checker_manager.run() File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/flake8_per_file_ignores.py", line 33, in run orig_run(self) File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/flake8/checker.py", line 338, in run self.run_parallel() File "/home/developer2/.local/share/virtualenvs/backend-0eAQt0K2/lib/python3.7/site-packages/flake8/checker.py", line 302, in run_parallel for ret in pool_map: File "/usr/lib/python3.7/multiprocessing/pool.py", line 774, in next raise value AttributeError: 'NoneType' object has no attribute 'lineno'
AttributeError
def check_attribute_name(self, node: ast.ClassDef) -> None: top_level_assigns = [ sub_node for sub_node in node.body if isinstance(sub_node, ast.Assign) ] for assignment in top_level_assigns: for target in assignment.targets: if not isinstance(target, ast.Name): continue name: Optional[str] = getattr(target, "id", None) if name and logical.is_upper_case_name(name): self._error_callback( naming.UpperCaseAttributeViolation(target, text=name), )
def check_attribute_name(self, node: ast.ClassDef) -> None: top_level_assigns = [ sub_node for sub_node in node.body if isinstance(sub_node, ast.Assign) ] for assignment in top_level_assigns: for target in assignment.targets: name = getattr(target, "id", None) if logical.is_upper_case_name(name): self._error_callback( naming.UpperCaseAttributeViolation(target, text=name), )
https://github.com/wemake-services/wemake-python-styleguide/issues/423
multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/flake8/checker.py", line 682, in _run_checks return checker.run_checks() File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/flake8/checker.py", line 612, in run_checks self.run_ast_checks() File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/flake8/checker.py", line 520, in run_ast_checks for (line_number, offset, text, check) in runner: File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/wemake_python_styleguide/checker.py", line 178, in run yield from self._run_checks(self.visitors) File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/wemake_python_styleguide/checker.py", line 166, in _run_checks visitor.run() File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/wemake_python_styleguide/visitors/base.py", line 140, in run self.visit(self.tree) File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ast.py", line 253, in visit return visitor(node) File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ast.py", line 261, in generic_visit self.visit(item) File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ast.py", line 253, in visit return visitor(node) File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/wemake_python_styleguide/visitors/ast/naming.py", line 154, in visit_ClassDef self._validator.check_attribute_name(node) File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/wemake_python_styleguide/visitors/ast/naming.py", line 117, in check_attribute_name if logical.is_upper_case_name(name): File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/wemake_python_styleguide/logics/naming/logical.py", line 70, in is_upper_case_name return any(character.isupper() for character in name) TypeError: 'NoneType' object is not iterable """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/flake8/__main__.py", line 4, in <module> cli.main() File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/flake8/main/cli.py", line 16, in main app.run(argv) File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/flake8/main/application.py", line 412, in run self._run(argv) File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/flake8/main/application.py", line 400, in _run self.run_checks() File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/flake8/main/application.py", line 318, in run_checks self.file_checker_manager.run() File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/flake8_per_file_ignores.py", line 33, in run orig_run(self) File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/flake8/checker.py", line 338, in run self.run_parallel() File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/flake8/checker.py", line 302, in run_parallel for ret in pool_map: File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 735, in next raise value TypeError: 'NoneType' object is not iterable
TypeError
def __init__(self, tree: Module, filename: str = constants.STDIN) -> None: """Creates new checker instance.""" self.tree = tree self.filename = filename
def __init__(self, tree: Module, filename: str = constants.STDIN) -> None: """Creates new checker instance.""" self.tree = maybe_set_parent(tree) self.filename = filename
https://github.com/wemake-services/wemake-python-styleguide/issues/112
multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 648, in _run_checks return checker.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 579, in run_checks self.run_ast_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 486, in run_ast_checks checker = self.run_check(plugin, tree=ast) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 435, in run_check return plugin['plugin'](**arguments) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/plugins/pyflakes.py", line 91, in __init__ withDoctest=with_doctest) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 495, in __init__ self.runDeferred(self._deferredFunctions) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 532, in runDeferred handler() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1172, in runFunction self.handleNode(stmt, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1310, in TRY self.handleNode(child, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1048, in NAME self.handleNodeStore(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 782, in handleNodeStore self.addBinding(node, binding) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 665, in addBinding if existing and not self.differentForks(node, existing.source): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 647, in differentForks if self.descendantOf(lnode, items, ancestor) ^ \ File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 637, in descendantOf if self.getCommonAncestor(node, a, stop): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 629, in getCommonAncestor if (lnode.depth > rnode.depth): AttributeError: 'ExceptHandler' object has no attribute 'depth' """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/bin/flake8", line 11, in <module> sys.exit(main()) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/cli.py", line 16, in main app.run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 396, in run self._run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 384, in _run self.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 310, in run_checks self.file_checker_manager.run() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 319, in run self.run_parallel() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 288, in run_parallel for ret in pool_map: File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 735, in next raise value AttributeError: 'ExceptHandler' object has no attribute 'depth'
AttributeError
def fix_line_number(tree: ast.AST) -> ast.AST: """ Adjusts line number for some nodes. They are set incorrectly for some collections. It might be either a bug or a feature. We do several checks here, to be sure that we won't get an incorrect line number. But, we basically check if there's a parent, so we can compare and adjust. Example:: print(( # should start from here 1, 2, 3, # actually starts from here )) """ affected = (ast.Tuple,) for node in ast.walk(tree): if isinstance(node, affected): parent_lineno = getattr( getattr(node, "wps_parent", None), "lineno", None, ) if parent_lineno and parent_lineno < node.lineno: node.lineno = node.lineno - 1 return tree
def fix_line_number(tree: ast.AST) -> ast.AST: """ Adjusts line number for some nodes. They are set incorrectly for some collections. It might be either a bug or a feature. We do several checks here, to be sure that we won't get an incorrect line number. But, we basically check if there's a parent, so we can compare and adjust. Example:: print(( # should start from here 1, 2, 3, # actually starts from here )) """ affected = (ast.Tuple,) for node in ast.walk(tree): if isinstance(node, affected): parent_lineno = getattr( getattr(node, "parent", None), "lineno", None, ) if parent_lineno and parent_lineno < node.lineno: node.lineno = node.lineno - 1 return tree
https://github.com/wemake-services/wemake-python-styleguide/issues/112
multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 648, in _run_checks return checker.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 579, in run_checks self.run_ast_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 486, in run_ast_checks checker = self.run_check(plugin, tree=ast) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 435, in run_check return plugin['plugin'](**arguments) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/plugins/pyflakes.py", line 91, in __init__ withDoctest=with_doctest) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 495, in __init__ self.runDeferred(self._deferredFunctions) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 532, in runDeferred handler() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1172, in runFunction self.handleNode(stmt, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1310, in TRY self.handleNode(child, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1048, in NAME self.handleNodeStore(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 782, in handleNodeStore self.addBinding(node, binding) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 665, in addBinding if existing and not self.differentForks(node, existing.source): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 647, in differentForks if self.descendantOf(lnode, items, ancestor) ^ \ File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 637, in descendantOf if self.getCommonAncestor(node, a, stop): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 629, in getCommonAncestor if (lnode.depth > rnode.depth): AttributeError: 'ExceptHandler' object has no attribute 'depth' """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/bin/flake8", line 11, in <module> sys.exit(main()) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/cli.py", line 16, in main app.run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 396, in run self._run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 384, in _run self.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 310, in run_checks self.file_checker_manager.run() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 319, in run self.run_parallel() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 288, in run_parallel for ret in pool_map: File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 735, in next raise value AttributeError: 'ExceptHandler' object has no attribute 'depth'
AttributeError
def _set_parent(tree: ast.AST) -> ast.AST: """ Sets parents for all nodes that do not have this prop. This step is required due to how `flake8` works. It does not set the same properties as `ast` module. This function was the cause of `issue-112`. Twice. Since the ``0.6.1`` we use ``'wps_parent'`` with a prefix. This should fix the issue with conflicting plugins. .. versionchanged:: 0.0.11 .. versionchanged:: 0.6.1 """ for statement in ast.walk(tree): for child in ast.iter_child_nodes(statement): setattr(child, "wps_parent", statement) return tree
def _set_parent(tree: ast.AST) -> ast.AST: """ Sets parents for all nodes that do not have this prop. This step is required due to how `flake8` works. It does not set the same properties as `ast` module. This function was the cause of `issue-112`. .. versionchanged:: 0.0.11 """ for statement in ast.walk(tree): for child in ast.iter_child_nodes(statement): setattr(child, "parent", statement) return tree
https://github.com/wemake-services/wemake-python-styleguide/issues/112
multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 648, in _run_checks return checker.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 579, in run_checks self.run_ast_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 486, in run_ast_checks checker = self.run_check(plugin, tree=ast) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 435, in run_check return plugin['plugin'](**arguments) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/plugins/pyflakes.py", line 91, in __init__ withDoctest=with_doctest) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 495, in __init__ self.runDeferred(self._deferredFunctions) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 532, in runDeferred handler() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1172, in runFunction self.handleNode(stmt, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1310, in TRY self.handleNode(child, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1048, in NAME self.handleNodeStore(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 782, in handleNodeStore self.addBinding(node, binding) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 665, in addBinding if existing and not self.differentForks(node, existing.source): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 647, in differentForks if self.descendantOf(lnode, items, ancestor) ^ \ File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 637, in descendantOf if self.getCommonAncestor(node, a, stop): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 629, in getCommonAncestor if (lnode.depth > rnode.depth): AttributeError: 'ExceptHandler' object has no attribute 'depth' """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/bin/flake8", line 11, in <module> sys.exit(main()) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/cli.py", line 16, in main app.run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 396, in run self._run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 384, in _run self.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 310, in run_checks self.file_checker_manager.run() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 319, in run self.run_parallel() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 288, in run_parallel for ret in pool_map: File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 735, in next raise value AttributeError: 'ExceptHandler' object has no attribute 'depth'
AttributeError
def _get_real_parent(self, node: Optional[ast.AST]) -> Optional[ast.AST]: """ Returns real number's parent. What can go wrong? 1. Number can be negative: ``x = -1``, so ``1`` has ``UnaryOp`` as parent, but should return ``Assign`` """ parent = getattr(node, "wps_parent", None) if isinstance(parent, self._proxy_parents): return self._get_real_parent(parent) return parent
def _get_real_parent(self, node: Optional[ast.AST]) -> Optional[ast.AST]: """ Returns real number's parent. What can go wrong? 1. Number can be negative: ``x = -1``, so ``1`` has ``UnaryOp`` as parent, but should return ``Assign`` """ parent = getattr(node, "parent", None) if isinstance(parent, self._proxy_parents): return self._get_real_parent(parent) return parent
https://github.com/wemake-services/wemake-python-styleguide/issues/112
multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 648, in _run_checks return checker.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 579, in run_checks self.run_ast_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 486, in run_ast_checks checker = self.run_check(plugin, tree=ast) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 435, in run_check return plugin['plugin'](**arguments) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/plugins/pyflakes.py", line 91, in __init__ withDoctest=with_doctest) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 495, in __init__ self.runDeferred(self._deferredFunctions) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 532, in runDeferred handler() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1172, in runFunction self.handleNode(stmt, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1310, in TRY self.handleNode(child, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1048, in NAME self.handleNodeStore(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 782, in handleNodeStore self.addBinding(node, binding) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 665, in addBinding if existing and not self.differentForks(node, existing.source): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 647, in differentForks if self.descendantOf(lnode, items, ancestor) ^ \ File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 637, in descendantOf if self.getCommonAncestor(node, a, stop): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 629, in getCommonAncestor if (lnode.depth > rnode.depth): AttributeError: 'ExceptHandler' object has no attribute 'depth' """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/bin/flake8", line 11, in <module> sys.exit(main()) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/cli.py", line 16, in main app.run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 396, in run self._run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 384, in _run self.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 310, in run_checks self.file_checker_manager.run() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 319, in run self.run_parallel() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 288, in run_parallel for ret in pool_map: File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 735, in next raise value AttributeError: 'ExceptHandler' object has no attribute 'depth'
AttributeError
def _check_members_count(self, node: ModuleMembers) -> None: """This method increases the number of module members.""" parent = getattr(node, "wps_parent", None) is_real_method = is_method(getattr(node, "function_type", None)) if isinstance(parent, ast.Module) and not is_real_method: self._public_items_count += 1
def _check_members_count(self, node: ModuleMembers) -> None: """This method increases the number of module members.""" parent = getattr(node, "parent", None) is_real_method = is_method(getattr(node, "function_type", None)) if isinstance(parent, ast.Module) and not is_real_method: self._public_items_count += 1
https://github.com/wemake-services/wemake-python-styleguide/issues/112
multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 648, in _run_checks return checker.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 579, in run_checks self.run_ast_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 486, in run_ast_checks checker = self.run_check(plugin, tree=ast) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 435, in run_check return plugin['plugin'](**arguments) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/plugins/pyflakes.py", line 91, in __init__ withDoctest=with_doctest) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 495, in __init__ self.runDeferred(self._deferredFunctions) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 532, in runDeferred handler() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1172, in runFunction self.handleNode(stmt, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1310, in TRY self.handleNode(child, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1048, in NAME self.handleNodeStore(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 782, in handleNodeStore self.addBinding(node, binding) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 665, in addBinding if existing and not self.differentForks(node, existing.source): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 647, in differentForks if self.descendantOf(lnode, items, ancestor) ^ \ File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 637, in descendantOf if self.getCommonAncestor(node, a, stop): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 629, in getCommonAncestor if (lnode.depth > rnode.depth): AttributeError: 'ExceptHandler' object has no attribute 'depth' """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/bin/flake8", line 11, in <module> sys.exit(main()) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/cli.py", line 16, in main app.run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 396, in run self._run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 384, in _run self.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 310, in run_checks self.file_checker_manager.run() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 319, in run self.run_parallel() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 288, in run_parallel for ret in pool_map: File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 735, in next raise value AttributeError: 'ExceptHandler' object has no attribute 'depth'
AttributeError
def _check_method(self, node: AnyFunctionDef) -> None: parent = getattr(node, "wps_parent", None) if isinstance(parent, ast.ClassDef): self._methods[parent] += 1
def _check_method(self, node: AnyFunctionDef) -> None: parent = getattr(node, "parent", None) if isinstance(parent, ast.ClassDef): self._methods[parent] += 1
https://github.com/wemake-services/wemake-python-styleguide/issues/112
multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 648, in _run_checks return checker.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 579, in run_checks self.run_ast_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 486, in run_ast_checks checker = self.run_check(plugin, tree=ast) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 435, in run_check return plugin['plugin'](**arguments) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/plugins/pyflakes.py", line 91, in __init__ withDoctest=with_doctest) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 495, in __init__ self.runDeferred(self._deferredFunctions) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 532, in runDeferred handler() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1172, in runFunction self.handleNode(stmt, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1310, in TRY self.handleNode(child, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1048, in NAME self.handleNodeStore(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 782, in handleNodeStore self.addBinding(node, binding) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 665, in addBinding if existing and not self.differentForks(node, existing.source): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 647, in differentForks if self.descendantOf(lnode, items, ancestor) ^ \ File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 637, in descendantOf if self.getCommonAncestor(node, a, stop): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 629, in getCommonAncestor if (lnode.depth > rnode.depth): AttributeError: 'ExceptHandler' object has no attribute 'depth' """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/bin/flake8", line 11, in <module> sys.exit(main()) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/cli.py", line 16, in main app.run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 396, in run self._run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 384, in _run self.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 310, in run_checks self.file_checker_manager.run() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 319, in run self.run_parallel() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 288, in run_parallel for ret in pool_map: File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 735, in next raise value AttributeError: 'ExceptHandler' object has no attribute 'depth'
AttributeError
def _update_variables( self, function: AnyFunctionDef, variable_def: ast.Name, ) -> None: """ Increases the counter of local variables. What is treated as a local variable? Check ``TooManyLocalsViolation`` documentation. """ function_variables = self.variables[function] if variable_def.id not in function_variables: if variable_def.id == UNUSED_VARIABLE: return parent = getattr(variable_def, "wps_parent", None) if isinstance(parent, self._not_contain_locals): return function_variables.append(variable_def.id)
def _update_variables( self, function: AnyFunctionDef, variable_def: ast.Name, ) -> None: """ Increases the counter of local variables. What is treated as a local variable? Check ``TooManyLocalsViolation`` documentation. """ function_variables = self.variables[function] if variable_def.id not in function_variables: if variable_def.id == UNUSED_VARIABLE: return parent = getattr(variable_def, "parent", None) if isinstance(parent, self._not_contain_locals): return function_variables.append(variable_def.id)
https://github.com/wemake-services/wemake-python-styleguide/issues/112
multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 648, in _run_checks return checker.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 579, in run_checks self.run_ast_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 486, in run_ast_checks checker = self.run_check(plugin, tree=ast) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 435, in run_check return plugin['plugin'](**arguments) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/plugins/pyflakes.py", line 91, in __init__ withDoctest=with_doctest) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 495, in __init__ self.runDeferred(self._deferredFunctions) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 532, in runDeferred handler() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1172, in runFunction self.handleNode(stmt, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1310, in TRY self.handleNode(child, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1048, in NAME self.handleNodeStore(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 782, in handleNodeStore self.addBinding(node, binding) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 665, in addBinding if existing and not self.differentForks(node, existing.source): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 647, in differentForks if self.descendantOf(lnode, items, ancestor) ^ \ File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 637, in descendantOf if self.getCommonAncestor(node, a, stop): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 629, in getCommonAncestor if (lnode.depth > rnode.depth): AttributeError: 'ExceptHandler' object has no attribute 'depth' """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/bin/flake8", line 11, in <module> sys.exit(main()) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/cli.py", line 16, in main app.run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 396, in run self._run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 384, in _run self.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 310, in run_checks self.file_checker_manager.run() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 319, in run self.run_parallel() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 288, in run_parallel for ret in pool_map: File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 735, in next raise value AttributeError: 'ExceptHandler' object has no attribute 'depth'
AttributeError
def _check_nested_function(self, node: AnyFunctionDef) -> None: parent = getattr(node, "wps_parent", None) is_inside_function = isinstance(parent, self._function_nodes) if is_inside_function and node.name not in NESTED_FUNCTIONS_WHITELIST: self.add_violation(NestedFunctionViolation(node, text=node.name))
def _check_nested_function(self, node: AnyFunctionDef) -> None: parent = getattr(node, "parent", None) is_inside_function = isinstance(parent, self._function_nodes) if is_inside_function and node.name not in NESTED_FUNCTIONS_WHITELIST: self.add_violation(NestedFunctionViolation(node, text=node.name))
https://github.com/wemake-services/wemake-python-styleguide/issues/112
multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 648, in _run_checks return checker.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 579, in run_checks self.run_ast_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 486, in run_ast_checks checker = self.run_check(plugin, tree=ast) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 435, in run_check return plugin['plugin'](**arguments) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/plugins/pyflakes.py", line 91, in __init__ withDoctest=with_doctest) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 495, in __init__ self.runDeferred(self._deferredFunctions) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 532, in runDeferred handler() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1172, in runFunction self.handleNode(stmt, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1310, in TRY self.handleNode(child, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1048, in NAME self.handleNodeStore(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 782, in handleNodeStore self.addBinding(node, binding) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 665, in addBinding if existing and not self.differentForks(node, existing.source): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 647, in differentForks if self.descendantOf(lnode, items, ancestor) ^ \ File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 637, in descendantOf if self.getCommonAncestor(node, a, stop): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 629, in getCommonAncestor if (lnode.depth > rnode.depth): AttributeError: 'ExceptHandler' object has no attribute 'depth' """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/bin/flake8", line 11, in <module> sys.exit(main()) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/cli.py", line 16, in main app.run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 396, in run self._run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 384, in _run self.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 310, in run_checks self.file_checker_manager.run() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 319, in run self.run_parallel() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 288, in run_parallel for ret in pool_map: File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 735, in next raise value AttributeError: 'ExceptHandler' object has no attribute 'depth'
AttributeError
def _check_nested_classes(self, node: ast.ClassDef) -> None: parent = getattr(node, "wps_parent", None) is_inside_class = isinstance(parent, ast.ClassDef) is_inside_function = isinstance(parent, self._function_nodes) if is_inside_class and node.name not in NESTED_CLASSES_WHITELIST: self.add_violation(NestedClassViolation(node, text=node.name)) elif is_inside_function: self.add_violation(NestedClassViolation(node, text=node.name))
def _check_nested_classes(self, node: ast.ClassDef) -> None: parent = getattr(node, "parent", None) is_inside_class = isinstance(parent, ast.ClassDef) is_inside_function = isinstance(parent, self._function_nodes) if is_inside_class and node.name not in NESTED_CLASSES_WHITELIST: self.add_violation(NestedClassViolation(node, text=node.name)) elif is_inside_function: self.add_violation(NestedClassViolation(node, text=node.name))
https://github.com/wemake-services/wemake-python-styleguide/issues/112
multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 648, in _run_checks return checker.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 579, in run_checks self.run_ast_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 486, in run_ast_checks checker = self.run_check(plugin, tree=ast) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 435, in run_check return plugin['plugin'](**arguments) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/plugins/pyflakes.py", line 91, in __init__ withDoctest=with_doctest) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 495, in __init__ self.runDeferred(self._deferredFunctions) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 532, in runDeferred handler() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1172, in runFunction self.handleNode(stmt, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1310, in TRY self.handleNode(child, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1048, in NAME self.handleNodeStore(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 782, in handleNodeStore self.addBinding(node, binding) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 665, in addBinding if existing and not self.differentForks(node, existing.source): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 647, in differentForks if self.descendantOf(lnode, items, ancestor) ^ \ File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 637, in descendantOf if self.getCommonAncestor(node, a, stop): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 629, in getCommonAncestor if (lnode.depth > rnode.depth): AttributeError: 'ExceptHandler' object has no attribute 'depth' """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/bin/flake8", line 11, in <module> sys.exit(main()) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/cli.py", line 16, in main app.run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 396, in run self._run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 384, in _run self.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 310, in run_checks self.file_checker_manager.run() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 319, in run self.run_parallel() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 288, in run_parallel for ret in pool_map: File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 735, in next raise value AttributeError: 'ExceptHandler' object has no attribute 'depth'
AttributeError
def _check_nested_lambdas(self, node: ast.Lambda) -> None: parent = getattr(node, "wps_parent", None) if isinstance(parent, ast.Lambda): self.add_violation(NestedFunctionViolation(node))
def _check_nested_lambdas(self, node: ast.Lambda) -> None: parent = getattr(node, "parent", None) if isinstance(parent, ast.Lambda): self.add_violation(NestedFunctionViolation(node))
https://github.com/wemake-services/wemake-python-styleguide/issues/112
multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 648, in _run_checks return checker.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 579, in run_checks self.run_ast_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 486, in run_ast_checks checker = self.run_check(plugin, tree=ast) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 435, in run_check return plugin['plugin'](**arguments) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/plugins/pyflakes.py", line 91, in __init__ withDoctest=with_doctest) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 495, in __init__ self.runDeferred(self._deferredFunctions) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 532, in runDeferred handler() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1172, in runFunction self.handleNode(stmt, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1310, in TRY self.handleNode(child, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1048, in NAME self.handleNodeStore(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 782, in handleNodeStore self.addBinding(node, binding) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 665, in addBinding if existing and not self.differentForks(node, existing.source): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 647, in differentForks if self.descendantOf(lnode, items, ancestor) ^ \ File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 637, in descendantOf if self.getCommonAncestor(node, a, stop): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 629, in getCommonAncestor if (lnode.depth > rnode.depth): AttributeError: 'ExceptHandler' object has no attribute 'depth' """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/bin/flake8", line 11, in <module> sys.exit(main()) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/cli.py", line 16, in main app.run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 396, in run self._run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 384, in _run self.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 310, in run_checks self.file_checker_manager.run() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 319, in run self.run_parallel() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 288, in run_parallel for ret in pool_map: File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 735, in next raise value AttributeError: 'ExceptHandler' object has no attribute 'depth'
AttributeError
def check_nested_import(self, node: AnyImport) -> None: parent = getattr(node, "wps_parent", None) if parent is not None and not isinstance(parent, ast.Module): self._error_callback(NestedImportViolation(node))
def check_nested_import(self, node: AnyImport) -> None: parent = getattr(node, "parent", None) if parent is not None and not isinstance(parent, ast.Module): self._error_callback(NestedImportViolation(node))
https://github.com/wemake-services/wemake-python-styleguide/issues/112
multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 648, in _run_checks return checker.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 579, in run_checks self.run_ast_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 486, in run_ast_checks checker = self.run_check(plugin, tree=ast) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 435, in run_check return plugin['plugin'](**arguments) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/plugins/pyflakes.py", line 91, in __init__ withDoctest=with_doctest) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 495, in __init__ self.runDeferred(self._deferredFunctions) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 532, in runDeferred handler() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1172, in runFunction self.handleNode(stmt, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1310, in TRY self.handleNode(child, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1048, in NAME self.handleNodeStore(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 782, in handleNodeStore self.addBinding(node, binding) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 665, in addBinding if existing and not self.differentForks(node, existing.source): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 647, in differentForks if self.descendantOf(lnode, items, ancestor) ^ \ File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 637, in descendantOf if self.getCommonAncestor(node, a, stop): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 629, in getCommonAncestor if (lnode.depth > rnode.depth): AttributeError: 'ExceptHandler' object has no attribute 'depth' """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/bin/flake8", line 11, in <module> sys.exit(main()) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/cli.py", line 16, in main app.run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 396, in run self._run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 384, in _run self.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 310, in run_checks self.file_checker_manager.run() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 319, in run self.run_parallel() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 288, in run_parallel for ret in pool_map: File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 735, in next raise value AttributeError: 'ExceptHandler' object has no attribute 'depth'
AttributeError
def _check_ifs(self, node: ast.comprehension) -> None: if len(node.ifs) > self._max_ifs: # We are trying to fix line number in the report, # since `comprehension` does not have this property. parent = getattr(node, "wps_parent", node) self.add_violation(MultipleIfsInComprehensionViolation(parent))
def _check_ifs(self, node: ast.comprehension) -> None: if len(node.ifs) > self._max_ifs: # We are trying to fix line number in the report, # since `comprehension` does not have this property. parent = getattr(node, "parent", node) self.add_violation(MultipleIfsInComprehensionViolation(parent))
https://github.com/wemake-services/wemake-python-styleguide/issues/112
multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 648, in _run_checks return checker.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 579, in run_checks self.run_ast_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 486, in run_ast_checks checker = self.run_check(plugin, tree=ast) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 435, in run_check return plugin['plugin'](**arguments) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/plugins/pyflakes.py", line 91, in __init__ withDoctest=with_doctest) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 495, in __init__ self.runDeferred(self._deferredFunctions) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 532, in runDeferred handler() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1172, in runFunction self.handleNode(stmt, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1310, in TRY self.handleNode(child, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1048, in NAME self.handleNodeStore(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 782, in handleNodeStore self.addBinding(node, binding) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 665, in addBinding if existing and not self.differentForks(node, existing.source): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 647, in differentForks if self.descendantOf(lnode, items, ancestor) ^ \ File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 637, in descendantOf if self.getCommonAncestor(node, a, stop): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 629, in getCommonAncestor if (lnode.depth > rnode.depth): AttributeError: 'ExceptHandler' object has no attribute 'depth' """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/bin/flake8", line 11, in <module> sys.exit(main()) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/cli.py", line 16, in main app.run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 396, in run self._run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 384, in _run self.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 310, in run_checks self.file_checker_manager.run() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 319, in run self.run_parallel() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 288, in run_parallel for ret in pool_map: File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 735, in next raise value AttributeError: 'ExceptHandler' object has no attribute 'depth'
AttributeError
def _check_fors(self, node: ast.comprehension) -> None: parent = getattr(node, "wps_parent", node) self._fors[parent] = len(parent.generators)
def _check_fors(self, node: ast.comprehension) -> None: parent = getattr(node, "parent", node) self._fors[parent] = len(parent.generators)
https://github.com/wemake-services/wemake-python-styleguide/issues/112
multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 648, in _run_checks return checker.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 579, in run_checks self.run_ast_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 486, in run_ast_checks checker = self.run_check(plugin, tree=ast) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 435, in run_check return plugin['plugin'](**arguments) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/plugins/pyflakes.py", line 91, in __init__ withDoctest=with_doctest) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 495, in __init__ self.runDeferred(self._deferredFunctions) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 532, in runDeferred handler() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1172, in runFunction self.handleNode(stmt, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1310, in TRY self.handleNode(child, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1048, in NAME self.handleNodeStore(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 782, in handleNodeStore self.addBinding(node, binding) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 665, in addBinding if existing and not self.differentForks(node, existing.source): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 647, in differentForks if self.descendantOf(lnode, items, ancestor) ^ \ File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 637, in descendantOf if self.getCommonAncestor(node, a, stop): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 629, in getCommonAncestor if (lnode.depth > rnode.depth): AttributeError: 'ExceptHandler' object has no attribute 'depth' """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/bin/flake8", line 11, in <module> sys.exit(main()) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/cli.py", line 16, in main app.run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 396, in run self._run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 384, in _run self.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 310, in run_checks self.file_checker_manager.run() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 319, in run self.run_parallel() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 288, in run_parallel for ret in pool_map: File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 735, in next raise value AttributeError: 'ExceptHandler' object has no attribute 'depth'
AttributeError
def _check_metadata(self, node: ast.Assign) -> None: node_parent = getattr(node, "wps_parent", None) if not isinstance(node_parent, ast.Module): return for target_node in node.targets: target_node_id = getattr(target_node, "id", None) if target_node_id in MODULE_METADATA_VARIABLES_BLACKLIST: self.add_violation( WrongModuleMetadataViolation(node, text=target_node_id), )
def _check_metadata(self, node: ast.Assign) -> None: node_parent = getattr(node, "parent", None) if not isinstance(node_parent, ast.Module): return for target_node in node.targets: target_node_id = getattr(target_node, "id", None) if target_node_id in MODULE_METADATA_VARIABLES_BLACKLIST: self.add_violation( WrongModuleMetadataViolation(node, text=target_node_id), )
https://github.com/wemake-services/wemake-python-styleguide/issues/112
multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 648, in _run_checks return checker.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 579, in run_checks self.run_ast_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 486, in run_ast_checks checker = self.run_check(plugin, tree=ast) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 435, in run_check return plugin['plugin'](**arguments) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/plugins/pyflakes.py", line 91, in __init__ withDoctest=with_doctest) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 495, in __init__ self.runDeferred(self._deferredFunctions) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 532, in runDeferred handler() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1172, in runFunction self.handleNode(stmt, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1310, in TRY self.handleNode(child, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1048, in NAME self.handleNodeStore(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 782, in handleNodeStore self.addBinding(node, binding) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 665, in addBinding if existing and not self.differentForks(node, existing.source): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 647, in differentForks if self.descendantOf(lnode, items, ancestor) ^ \ File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 637, in descendantOf if self.getCommonAncestor(node, a, stop): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 629, in getCommonAncestor if (lnode.depth > rnode.depth): AttributeError: 'ExceptHandler' object has no attribute 'depth' """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/bin/flake8", line 11, in <module> sys.exit(main()) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/cli.py", line 16, in main app.run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 396, in run self._run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 384, in _run self.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 310, in run_checks self.file_checker_manager.run() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 319, in run self.run_parallel() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 288, in run_parallel for ret in pool_map: File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 735, in next raise value AttributeError: 'ExceptHandler' object has no attribute 'depth'
AttributeError
def _check_expression( self, node: ast.Expr, is_first: bool = False, ) -> None: if isinstance(node.value, self._have_effect): return if is_first and is_doc_string(node): parent = getattr(node, "wps_parent", None) if isinstance(parent, self._have_doc_strings): return self.add_violation(StatementHasNoEffectViolation(node))
def _check_expression( self, node: ast.Expr, is_first: bool = False, ) -> None: if isinstance(node.value, self._have_effect): return if is_first and is_doc_string(node): parent = getattr(node, "parent", None) if isinstance(parent, self._have_doc_strings): return self.add_violation(StatementHasNoEffectViolation(node))
https://github.com/wemake-services/wemake-python-styleguide/issues/112
multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 648, in _run_checks return checker.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 579, in run_checks self.run_ast_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 486, in run_ast_checks checker = self.run_check(plugin, tree=ast) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 435, in run_check return plugin['plugin'](**arguments) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/plugins/pyflakes.py", line 91, in __init__ withDoctest=with_doctest) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 495, in __init__ self.runDeferred(self._deferredFunctions) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 532, in runDeferred handler() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1172, in runFunction self.handleNode(stmt, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1310, in TRY self.handleNode(child, node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 816, in handleChildren self.handleNode(node, tree) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 863, in handleNode handler(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 1048, in NAME self.handleNodeStore(node) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 782, in handleNodeStore self.addBinding(node, binding) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 665, in addBinding if existing and not self.differentForks(node, existing.source): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 647, in differentForks if self.descendantOf(lnode, items, ancestor) ^ \ File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 637, in descendantOf if self.getCommonAncestor(node, a, stop): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/pyflakes/checker.py", line 629, in getCommonAncestor if (lnode.depth > rnode.depth): AttributeError: 'ExceptHandler' object has no attribute 'depth' """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/bin/flake8", line 11, in <module> sys.exit(main()) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/cli.py", line 16, in main app.run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 396, in run self._run(argv) File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 384, in _run self.run_checks() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/main/application.py", line 310, in run_checks self.file_checker_manager.run() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 319, in run self.run_parallel() File "/Users/sobolev/Documents/PyCharmProjects/rostelecom_svetochka/.venv/lib/python3.6/site-packages/flake8/checker.py", line 288, in run_parallel for ret in pool_map: File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 735, in next raise value AttributeError: 'ExceptHandler' object has no attribute 'depth'
AttributeError
def do_render(self, cr, widget, background_area, cell_area, flags): vw_tags = self.__count_viewable_tags() count = 0 # Select source if self.tag_list is not None: tags = self.tag_list elif self.tag is not None: tags = [self.tag] else: return if self.config.get("dark_mode"): symbolic_color = Gdk.RGBA(0.9, 0.9, 0.9, 1) else: symbolic_color = Gdk.RGBA(0, 0, 0, 1) # Drawing context gdkcontext = cr gdkcontext.set_antialias(cairo.ANTIALIAS_NONE) # Coordinates of the origin point x_align = self.get_property("xalign") y_align = self.get_property("yalign") padding = self.PADDING orig_x = cell_area.x + int( (cell_area.width - 16 * vw_tags - padding * 2 * (vw_tags - 1)) * x_align ) orig_y = cell_area.y + int((cell_area.height - 16) * y_align) # We draw the icons & squares for my_tag in tags: my_tag_icon = my_tag.get_attribute("icon") my_tag_color = my_tag.get_attribute("color") rect_x = orig_x + self.PADDING * 2 * count + 16 * count rect_y = orig_y if my_tag_icon: if my_tag_icon in self.SYMBOLIC_ICONS: icon_theme = Gtk.IconTheme.get_default() info = icon_theme.lookup_icon(my_tag_icon, 16, 0) load = info.load_symbolic(symbolic_color) pixbuf = load[0] Gdk.cairo_set_source_pixbuf(gdkcontext, pixbuf, rect_x, rect_y) gdkcontext.paint() count += 1 else: layout = PangoCairo.create_layout(cr) layout.set_markup(my_tag_icon, -1) cr.move_to(rect_x - 2, rect_y - 1) PangoCairo.show_layout(cr, layout) count += 1 elif my_tag_color: # Draw rounded rectangle my_color = Gdk.RGBA() my_color.parse(my_tag_color) Gdk.cairo_set_source_rgba(gdkcontext, my_color) self.__roundedrec(gdkcontext, rect_x, rect_y, 16, 16, 8) gdkcontext.fill() count += 1 # Outer line Gdk.cairo_set_source_rgba(gdkcontext, Gdk.RGBA(0, 0, 0, 0.20)) gdkcontext.set_line_width(1.0) self.__roundedrec(gdkcontext, rect_x, rect_y, 16, 16, 8) gdkcontext.stroke() if self.tag and my_tag: my_tag_icon = my_tag.get_attribute("icon") my_tag_color = my_tag.get_attribute("color") if not my_tag_icon and not my_tag_color: # Draw rounded rectangle Gdk.cairo_set_source_rgba(gdkcontext, Gdk.RGBA(0.95, 0.95, 0.95, 1)) self.__roundedrec(gdkcontext, rect_x, rect_y, 16, 16, 8) gdkcontext.fill() # Outer line Gdk.cairo_set_source_rgba(gdkcontext, Gdk.RGBA(0, 0, 0, 0.20)) gdkcontext.set_line_width(1.0) self.__roundedrec(gdkcontext, rect_x, rect_y, 16, 16, 8) gdkcontext.stroke()
def do_render(self, cr, widget, background_area, cell_area, flags): vw_tags = self.__count_viewable_tags() count = 0 # Select source if self.tag_list is not None: tags = self.tag_list elif self.tag is not None: tags = [self.tag] else: return if self.config.get("dark_mode"): symbolic_color = Gdk.RGBA(0.9, 0.9, 0.9, 1) else: symbolic_color = Gdk.RGBA(0, 0, 0, 1) # Drawing context gdkcontext = cr gdkcontext.set_antialias(cairo.ANTIALIAS_NONE) # Coordinates of the origin point x_align = self.get_property("xalign") y_align = self.get_property("yalign") padding = self.PADDING orig_x = cell_area.x + int( (cell_area.width - 16 * vw_tags - padding * 2 * (vw_tags - 1)) * x_align ) orig_y = cell_area.y + int((cell_area.height - 16) * y_align) # We draw the icons & squares for my_tag in tags: my_tag_icon = my_tag.get_attribute("icon") my_tag_color = my_tag.get_attribute("color") rect_x = orig_x + self.PADDING * 2 * count + 16 * count rect_y = orig_y if my_tag_icon: if my_tag_icon in self.SYMBOLIC_ICONS: icon_theme = Gtk.IconTheme.get_default() info = icon_theme.lookup_icon(my_tag_icon, 16, 0) load = info.load_symbolic(symbolic_color) pixbuf = load[0] Gdk.cairo_set_source_pixbuf(gdkcontext, pixbuf, rect_x, rect_y) gdkcontext.paint() count += 1 else: layout = PangoCairo.create_layout(cr) layout.set_markup(my_tag_icon, -1) cr.move_to(rect_x - 2, rect_y - 1) PangoCairo.show_layout(cr, layout) count += 1 elif my_tag_color: # Draw rounded rectangle my_color = Gdk.color_parse(my_tag_color) Gdk.cairo_set_source_color(gdkcontext, my_color) self.__roundedrec(gdkcontext, rect_x, rect_y, 16, 16, 8) gdkcontext.fill() count += 1 # Outer line Gdk.cairo_set_source_rgba(gdkcontext, Gdk.RGBA(0, 0, 0, 0.20)) gdkcontext.set_line_width(1.0) self.__roundedrec(gdkcontext, rect_x, rect_y, 16, 16, 8) gdkcontext.stroke() if self.tag and my_tag: my_tag_icon = my_tag.get_attribute("icon") my_tag_color = my_tag.get_attribute("color") if not my_tag_icon and not my_tag_color: # Draw rounded rectangle Gdk.cairo_set_source_rgba(gdkcontext, Gdk.RGBA(0.95, 0.95, 0.95, 1)) self.__roundedrec(gdkcontext, rect_x, rect_y, 16, 16, 8) gdkcontext.fill() # Outer line Gdk.cairo_set_source_rgba(gdkcontext, Gdk.RGBA(0, 0, 0, 0.20)) gdkcontext.set_line_width(1.0) self.__roundedrec(gdkcontext, rect_x, rect_y, 16, 16, 8) gdkcontext.stroke()
https://github.com/getting-things-gnome/gtg/issues/411
Traceback (most recent call last): File "/app/lib/python3.7/site-packages/GTG/gtk/browser/simple_color_selector.py", line 108, in on_expose self.__draw(cr) File "/app/lib/python3.7/site-packages/GTG/gtk/browser/simple_color_selector.py", line 71, in __draw Gdk.cairo_set_source_color(gdkcontext, my_color) TypeError: Argument 1 does not allow None as a value Traceback (most recent call last): File "/app/lib/python3.7/site-packages/GTG/gtk/browser/simple_color_selector.py", line 108, in on_expose self.__draw(cr) File "/app/lib/python3.7/site-packages/GTG/gtk/browser/simple_color_selector.py", line 71, in __draw Gdk.cairo_set_source_color(gdkcontext, my_color) TypeError: Argument 1 does not allow None as a value (gtg:2): Gtk-WARNING **: 10:43:10.798: drawing failure for widget 'GTG+gtk+browser+simple_color_selector+SimpleColorSelectorPaletteItem': NULL pointer (gtg:2): Gtk-WARNING **: 10:43:10.798: drawing failure for widget 'GtkBox': NULL pointer (gtg:2): Gtk-WARNING **: 10:43:10.798: drawing failure for widget 'GtkBox': NULL pointer (gtg:2): Gtk-WARNING **: 10:43:10.798: drawing failure for widget 'GtkAlignment': NULL pointer (gtg:2): Gtk-WARNING **: 10:43:10.798: drawing failure for widget 'GTG+gtk+browser+simple_color_selector+SimpleColorSelector': NULL pointer (gtg:2): Gtk-WARNING **: 10:43:10.798: drawing failure for widget 'GtkAlignment': NULL pointer (gtg:2): Gtk-WARNING **: 10:43:10.798: drawing failure for widget 'GtkBox': NULL pointer (gtg:2): Gtk-WARNING **: 10:43:10.798: drawing failure for widget 'GtkBox': NULL pointer (gtg:2): Gtk-WARNING **: 10:43:10.798: drawing failure for widget 'GTG+gtk+browser+tag_editor+TagEditor': NULL pointer python3: ../../src/cairo.c:524: cairo_destroy: Assertion `CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&amp;cr->ref_count)' failed.
TypeError
def __draw(self, cr): """Draws the widget""" alloc = self.get_allocation() # FIXME - why to use a special variables? alloc_w, alloc_h = alloc.width, alloc.height # Drawing context # cr_ctxt = Gdk.cairo_create(self.window) # gdkcontext = Gdk.CairoContext(cr_ctxt) # FIXME gdkcontext = cr # Draw rectangle if self.color is not None: my_color = Gdk.RGBA() my_color.parse(self.color) Gdk.cairo_set_source_rgba(gdkcontext, my_color) else: Gdk.cairo_set_source_rgba(gdkcontext, Gdk.RGBA(0, 0, 0, 0)) gdkcontext.rectangle(0, 0, alloc_w, alloc_h) gdkcontext.fill() # Outer line Gdk.cairo_set_source_rgba(gdkcontext, Gdk.RGBA(0, 0, 0, 0.30)) gdkcontext.set_line_width(2.0) gdkcontext.rectangle(0, 0, alloc_w, alloc_h) gdkcontext.stroke() # If selected draw a symbol if self.selected: size = alloc_h * 0.50 - 3 pos_x = math.floor((alloc_w - size) / 2) pos_y = math.floor((alloc_h - size) / 2) Gdk.cairo_set_source_rgba(gdkcontext, Gdk.RGBA(255, 255, 255, 0.80)) gdkcontext.arc(alloc_w / 2, alloc_h / 2, size / 2 + 3, 0, 2 * math.pi) gdkcontext.fill() gdkcontext.set_line_width(1.0) Gdk.cairo_set_source_rgba(gdkcontext, Gdk.RGBA(0, 0, 0, 0.20)) gdkcontext.arc(alloc_w / 2, alloc_h / 2, size / 2 + 3, 0, 2 * math.pi) gdkcontext.stroke() Gdk.cairo_set_source_rgba(gdkcontext, Gdk.RGBA(0, 0, 0, 0.50)) gdkcontext.set_line_width(3.0) gdkcontext.move_to(pos_x, pos_y + size / 2) gdkcontext.line_to(pos_x + size / 2, pos_y + size) gdkcontext.line_to(pos_x + size, pos_y) gdkcontext.stroke()
def __draw(self, cr): """Draws the widget""" alloc = self.get_allocation() # FIXME - why to use a special variables? alloc_w, alloc_h = alloc.width, alloc.height # Drawing context # cr_ctxt = Gdk.cairo_create(self.window) # gdkcontext = Gdk.CairoContext(cr_ctxt) # FIXME gdkcontext = cr # Draw rectangle if self.color is not None: my_color = Gdk.color_parse(self.color) Gdk.cairo_set_source_color(gdkcontext, my_color) else: Gdk.cairo_set_source_rgba(gdkcontext, Gdk.RGBA(0, 0, 0, 0)) gdkcontext.rectangle(0, 0, alloc_w, alloc_h) gdkcontext.fill() # Outer line Gdk.cairo_set_source_rgba(gdkcontext, Gdk.RGBA(0, 0, 0, 0.30)) gdkcontext.set_line_width(2.0) gdkcontext.rectangle(0, 0, alloc_w, alloc_h) gdkcontext.stroke() # If selected draw a symbol if self.selected: size = alloc_h * 0.50 - 3 pos_x = math.floor((alloc_w - size) / 2) pos_y = math.floor((alloc_h - size) / 2) Gdk.cairo_set_source_rgba(gdkcontext, Gdk.RGBA(255, 255, 255, 0.80)) gdkcontext.arc(alloc_w / 2, alloc_h / 2, size / 2 + 3, 0, 2 * math.pi) gdkcontext.fill() gdkcontext.set_line_width(1.0) Gdk.cairo_set_source_rgba(gdkcontext, Gdk.RGBA(0, 0, 0, 0.20)) gdkcontext.arc(alloc_w / 2, alloc_h / 2, size / 2 + 3, 0, 2 * math.pi) gdkcontext.stroke() Gdk.cairo_set_source_rgba(gdkcontext, Gdk.RGBA(0, 0, 0, 0.50)) gdkcontext.set_line_width(3.0) gdkcontext.move_to(pos_x, pos_y + size / 2) gdkcontext.line_to(pos_x + size / 2, pos_y + size) gdkcontext.line_to(pos_x + size, pos_y) gdkcontext.stroke()
https://github.com/getting-things-gnome/gtg/issues/411
Traceback (most recent call last): File "/app/lib/python3.7/site-packages/GTG/gtk/browser/simple_color_selector.py", line 108, in on_expose self.__draw(cr) File "/app/lib/python3.7/site-packages/GTG/gtk/browser/simple_color_selector.py", line 71, in __draw Gdk.cairo_set_source_color(gdkcontext, my_color) TypeError: Argument 1 does not allow None as a value Traceback (most recent call last): File "/app/lib/python3.7/site-packages/GTG/gtk/browser/simple_color_selector.py", line 108, in on_expose self.__draw(cr) File "/app/lib/python3.7/site-packages/GTG/gtk/browser/simple_color_selector.py", line 71, in __draw Gdk.cairo_set_source_color(gdkcontext, my_color) TypeError: Argument 1 does not allow None as a value (gtg:2): Gtk-WARNING **: 10:43:10.798: drawing failure for widget 'GTG+gtk+browser+simple_color_selector+SimpleColorSelectorPaletteItem': NULL pointer (gtg:2): Gtk-WARNING **: 10:43:10.798: drawing failure for widget 'GtkBox': NULL pointer (gtg:2): Gtk-WARNING **: 10:43:10.798: drawing failure for widget 'GtkBox': NULL pointer (gtg:2): Gtk-WARNING **: 10:43:10.798: drawing failure for widget 'GtkAlignment': NULL pointer (gtg:2): Gtk-WARNING **: 10:43:10.798: drawing failure for widget 'GTG+gtk+browser+simple_color_selector+SimpleColorSelector': NULL pointer (gtg:2): Gtk-WARNING **: 10:43:10.798: drawing failure for widget 'GtkAlignment': NULL pointer (gtg:2): Gtk-WARNING **: 10:43:10.798: drawing failure for widget 'GtkBox': NULL pointer (gtg:2): Gtk-WARNING **: 10:43:10.798: drawing failure for widget 'GtkBox': NULL pointer (gtg:2): Gtk-WARNING **: 10:43:10.798: drawing failure for widget 'GTG+gtk+browser+tag_editor+TagEditor': NULL pointer python3: ../../src/cairo.c:524: cairo_destroy: Assertion `CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&amp;cr->ref_count)' failed.
TypeError
def insert_existing_subtask(self, tid: str, line: int = None) -> None: """Insert an existing subtask in the buffer.""" # Check if the task exists first if not self.req.has_task(tid): log.debug(f"Task {tid} not found") return if line is not None: start = self.buffer.get_iter_at_line(line) else: start = self.buffer.get_end_iter() self.buffer.insert(start, "\n") start.forward_line() line = start.get_line() # Add subtask name task = self.req.get_task(tid) self.buffer.insert(start, task.get_title()) # Reset iterator start = self.buffer.get_iter_at_line(line) # Add checkbox self.add_checkbox(tid, start) # Apply link to subtask text end = start.copy() end.forward_to_line_end() link_tag = InternalLinkTag(tid, task.get_status()) self.table.add(link_tag) self.buffer.apply_tag(link_tag, start, end) self.tags_applied.append(link_tag) # Apply subtask tag to everything start.backward_char() subtask_tag = SubTaskTag(tid) self.table.add(subtask_tag) self.buffer.apply_tag(subtask_tag, start, end) self.subtasks["tags"].append(tid)
def insert_existing_subtask(self, tid: str, line: int = None) -> None: """Insert an existing subtask in the buffer.""" # Check if the task exists first if not self.req.has_task(tid): log.debug(f"Task {tid} not found") return if line is not None: start = self.buffer.get_iter_at_line(line) else: start = self.buffer.get_end_iter() self.buffer.insert(start, "\n") start.forward_line() line = start.get_line() # Add subtask name task = self.req.get_task(tid) self.buffer.insert(start, task.get_title()) # Reset iterator start = self.buffer.get_iter_at_line(line) # Add checkbox self.add_checkbox(tid, start) # Apply link to subtask text end = start.copy() end.forward_to_line_end() link_tag = InternalLinkTag(tid, task.get_status()) self.table.add(link_tag) self.buffer.apply_tag(link_tag, start, end) self.tags_applied.append(link_tag) # Apply subtask tag to everything start.backward_char() subtask_tag = SubTaskTag(tid) self.table.add(subtask_tag) self.buffer.apply_tag(subtask_tag, start, end) self.subtasks["tags"].append(tid) # Make sure subtasks can be deleted when removed in the text editor task.can_be_deleted = True
https://github.com/getting-things-gnome/gtg/issues/496
2020-10-25 02:22:28,806 - ERROR - application:open_task:483 - Task 2376f725-ab76-4de9-b97a-489bf9bfb3d2 could not be found! Traceback (most recent call last): File "GTG/gtk/editor/text_tags.py", line 132, in on_tag view.open_subtask_cb(self.tid) File "GTG/gtk/editor/editor.py", line 709, in open_subtask self.app.close_task(task.parents[0]) AttributeError: 'NoneType' object has no attribute 'parents'
AttributeError
def delete_editor_task(self, action, params): """Callback to delete the task currently open.""" editor = self.get_active_editor() task = editor.task if task.is_new(): self.close_task(task.get_id()) else: self.delete_tasks([task.get_id()], editor.window)
def delete_editor_task(self, action, params): """Callback to delete the task currently open.""" editor = self.get_active_editor() task = editor.task if task.is_new(): self.close_task(task.get_id(), editor.window) else: self.delete_tasks([task.get_id()], editor.window)
https://github.com/getting-things-gnome/gtg/issues/338
Traceback (most recent call last): File "GTG/gtk/application.py", line 292, in delete_editor_task self.close_task(task.get_id(), editor.window) TypeError: close_task() takes 2 positional arguments but 3 were given
TypeError
def close_focused_task(self, action, params): """Callback to close currently focused task editor.""" editor = self.get_active_editor() if editor: self.close_task(editor.task.get_id())
def close_focused_task(self, action, params): """Callback to close currently focused task editor.""" if self.open_tasks: tid = self.get_active_editor().task.get_id() self.close_task(tid)
https://github.com/getting-things-gnome/gtg/issues/290
WARNING - application:close_task:467 - Tried to close tid d318eaed-03de-42dd-adfd-66a44bf2261c but it is not open Traceback (most recent call last): File "GTG/gtk/application.py", line 290, in close_focused_task tid = self.get_active_editor().task.get_id() AttributeError: 'NoneType' object has no attribute 'task' WARNING - application:close_task:467 - Tried to close tid f53f937f-72a1-450a-b2ae-f4038a401ac3 but it is not open
AttributeError
def close_task(self, tid): """Close a task editor window.""" try: editor = self.open_tasks[tid] editor.close() open_tasks = self.config.get("opened_tasks") if tid in open_tasks: open_tasks.remove(tid) self.config.set("opened_tasks", open_tasks) except KeyError: log.debug(f"Tried to close tid {tid} but it is not open")
def close_task(self, tid): """Close a task editor window.""" if tid in self.open_tasks: editor = self.open_tasks[tid] # We have to remove the tid first, otherwise # close_task would be called once again # by editor.close del self.open_tasks[tid] editor.close() open_tasks = self.config.get("opened_tasks") if tid in open_tasks: open_tasks.remove(tid) self.config.set("opened_tasks", open_tasks) else: log.warn(f"Tried to close tid {tid} but it is not open")
https://github.com/getting-things-gnome/gtg/issues/290
WARNING - application:close_task:467 - Tried to close tid d318eaed-03de-42dd-adfd-66a44bf2261c but it is not open Traceback (most recent call last): File "GTG/gtk/application.py", line 290, in close_focused_task tid = self.get_active_editor().task.get_id() AttributeError: 'NoneType' object has no attribute 'task' WARNING - application:close_task:467 - Tried to close tid f53f937f-72a1-450a-b2ae-f4038a401ac3 but it is not open
AttributeError
def destruction(self, _=None): """Callback when destroying the window.""" # Save should be also called when buffer is modified self.pengine.onTaskClose(self.plugin_api) self.pengine.remove_api(self.plugin_api) tid = self.task.get_id() if self.task.is_new(): self.req.delete_task(tid) else: self.save() [sub.set_to_keep() for sub in self.task.get_subtasks() if sub] try: del self.app.open_tasks[tid] except KeyError: log.debug(f"Task {tid} was already removed from the open list")
def destruction(self, a=None): # Save should be also called when buffer is modified self.pengine.onTaskClose(self.plugin_api) self.pengine.remove_api(self.plugin_api) tid = self.task.get_id() if self.task.is_new(): self.req.delete_task(tid) else: self.save() for i in self.task.get_subtasks(): if i: i.set_to_keep() self.app.close_task(tid)
https://github.com/getting-things-gnome/gtg/issues/290
WARNING - application:close_task:467 - Tried to close tid d318eaed-03de-42dd-adfd-66a44bf2261c but it is not open Traceback (most recent call last): File "GTG/gtk/application.py", line 290, in close_focused_task tid = self.get_active_editor().task.get_id() AttributeError: 'NoneType' object has no attribute 'task' WARNING - application:close_task:467 - Tried to close tid f53f937f-72a1-450a-b2ae-f4038a401ac3 but it is not open
AttributeError
def open_edit_backends(self, sender=None, backend_id=None): self.edit_backends_dialog = BackendsDialog(self.req) self.edit_backends_dialog.dialog.insert_action_group("app", self) self.edit_backends_dialog.activate() if backend_id: self.edit_backends_dialog.show_config_for_backend(backend_id)
def open_edit_backends(self, sender=None, backend_id=None): if not self.edit_backends_dialog: self.edit_backends_dialog = BackendsDialog(self.req) self.edit_backends_dialog.dialog.insert_action_group("app", self) self.edit_backends_dialog.activate() if backend_id is not None: self.edit_backends_dialog.show_config_for_backend(backend_id)
https://github.com/getting-things-gnome/gtg/issues/284
Traceback (most recent call last): File "/usr/lib/python3/dist-packages/gi/overrides/Gtk.py", line 110, in _builder_connect_callback handler, args = _extract_handler_and_args(obj_or_map, handler_name) File "/usr/lib/python3/dist-packages/gi/overrides/Gtk.py", line 90, in _extract_handler_and_args raise AttributeError('Handler %s not found' % handler_name) AttributeError: Handler on_BackendsDialog_delete_event not found Traceback (most recent call last): File "/usr/lib/python3/dist-packages/gi/overrides/Gtk.py", line 110, in _builder_connect_callback handler, args = _extract_handler_and_args(obj_or_map, handler_name) File "/usr/lib/python3/dist-packages/gi/overrides/Gtk.py", line 90, in _extract_handler_and_args raise AttributeError('Handler %s not found' % handler_name) AttributeError: Handler on_close_button_clicked not found
AttributeError
def get_added_date_string(self): FORMAT = "%Y-%m-%dT%H:%M:%S" if self.added_date: return self.added_date.strftime(FORMAT) else: return datetime.now().strftime(FORMAT)
def get_added_date_string(self): if self.added_date: return self.added_date.strftime("%Y-%m-%dT%H:%M:%S") else: return Date.now()
https://github.com/getting-things-gnome/gtg/issues/256
Traceback (most recent call last): File "/home/jeff/gtg/GTG/gtk/browser/modify_tags.py", line 94, in on_confirm task.add_tag(tag) File "/home/jeff/gtg/GTG/core/task.py", line 707, in add_tag cgi.escape(tagname), sep, c) AttributeError: module 'cgi' has no attribute 'escape' Exception in thread Thread-2: Traceback (most recent call last): File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() File "/usr/lib/python3.8/threading.py", line 1254, in run self.function(*self.args, **self.kwargs) File "/home/jeff/gtg/GTG/backends/generic_backend.py", line 649, in launch_setting_thread self.set_task(task) File "/home/jeff/gtg/GTG/backends/backend_localfile.py", line 166, in set_task t_xml = taskxml.task_to_xml(self.doc, task) File "/home/jeff/gtg/GTG/core/taskxml.py", line 129, in task_to_xml cleanxml.addTextNode(doc, t_xml, "addeddate", task.get_added_date_string()) File "/home/jeff/gtg/GTG/core/cleanxml.py", line 80, in addTextNode element.appendChild(doc.createTextNode(content)) File "/usr/lib/python3.8/xml/dom/minidom.py", line 1659, in createTextNode raise TypeError("node contents must be a string") TypeError: node contents must be a string
AttributeError
def set_title(self, title, transaction_ids=[]): """Sets the task title""" title = html.escape(title) result = self.rtm.tasks.setName( timeline=self.timeline, list_id=self.rtm_list.id, taskseries_id=self.rtm_taskseries.id, task_id=self.rtm_task.id, name=title, ) transaction_ids.append(result.transaction.id)
def set_title(self, title, transaction_ids=[]): """Sets the task title""" title = cgi.escape(title) result = self.rtm.tasks.setName( timeline=self.timeline, list_id=self.rtm_list.id, taskseries_id=self.rtm_taskseries.id, task_id=self.rtm_task.id, name=title, ) transaction_ids.append(result.transaction.id)
https://github.com/getting-things-gnome/gtg/issues/259
Traceback (most recent call last): File "/home/jeff/gtg/GTG/gtk/editor/taskview.py", line 550, in modified self._detect_tag(buff, local_start, local_end) File "/home/jeff/gtg/GTG/gtk/editor/taskview.py", line 740, in _detect_tag self.add_tag_callback(my_word) File "/home/jeff/gtg/GTG/core/task.py", line 707, in add_tag cgi.escape(tagname), sep, c) AttributeError: module 'cgi' has no attribute 'escape'
AttributeError
def set_text(self, text, transaction_ids=[]): """ deletes all the old notes in a task and sets a single note with the given text """ # delete old notes notes = self.rtm_taskseries.notes if notes: note_list = self.__getattr_the_rtm_way(notes, "note") for note_id in [note.id for note in note_list]: result = self.rtm.tasksNotes.delete(timeline=self.timeline, note_id=note_id) transaction_ids.append(result.transaction.id) if text == "": return text = html.escape(text) # RTM does not support well long notes (that is, it denies the request) # Thus, we split long text in chunks. To make them show in the correct # order on the website, we have to upload them from the last to the # first (they show the most recent on top) text_cursor_end = len(text) while True: text_cursor_start = text_cursor_end - 1000 if text_cursor_start < 0: text_cursor_start = 0 result = self.rtm.tasksNotes.add( timeline=self.timeline, list_id=self.rtm_list.id, taskseries_id=self.rtm_taskseries.id, task_id=self.rtm_task.id, note_title="", note_text=text[text_cursor_start:text_cursor_end], ) transaction_ids.append(result.transaction.id) if text_cursor_start <= 0: break text_cursor_end = text_cursor_start - 1
def set_text(self, text, transaction_ids=[]): """ deletes all the old notes in a task and sets a single note with the given text """ # delete old notes notes = self.rtm_taskseries.notes if notes: note_list = self.__getattr_the_rtm_way(notes, "note") for note_id in [note.id for note in note_list]: result = self.rtm.tasksNotes.delete(timeline=self.timeline, note_id=note_id) transaction_ids.append(result.transaction.id) if text == "": return text = cgi.escape(text) # RTM does not support well long notes (that is, it denies the request) # Thus, we split long text in chunks. To make them show in the correct # order on the website, we have to upload them from the last to the # first (they show the most recent on top) text_cursor_end = len(text) while True: text_cursor_start = text_cursor_end - 1000 if text_cursor_start < 0: text_cursor_start = 0 result = self.rtm.tasksNotes.add( timeline=self.timeline, list_id=self.rtm_list.id, taskseries_id=self.rtm_taskseries.id, task_id=self.rtm_task.id, note_title="", note_text=text[text_cursor_start:text_cursor_end], ) transaction_ids.append(result.transaction.id) if text_cursor_start <= 0: break text_cursor_end = text_cursor_start - 1
https://github.com/getting-things-gnome/gtg/issues/259
Traceback (most recent call last): File "/home/jeff/gtg/GTG/gtk/editor/taskview.py", line 550, in modified self._detect_tag(buff, local_start, local_end) File "/home/jeff/gtg/GTG/gtk/editor/taskview.py", line 740, in _detect_tag self.add_tag_callback(my_word) File "/home/jeff/gtg/GTG/core/task.py", line 707, in add_tag cgi.escape(tagname), sep, c) AttributeError: module 'cgi' has no attribute 'escape'
AttributeError
def set_text(self, texte): self.can_be_deleted = False if texte != "<content/>": # defensive programmation to filter bad formatted tasks if not texte.startswith("<content>"): texte = html.escape(texte, quote=True) texte = f"<content>{texte}" if not texte.endswith("</content>"): texte = f"{texte}</content>" self.content = str(texte) else: self.content = ""
def set_text(self, texte): self.can_be_deleted = False if texte != "<content/>": # defensive programmation to filter bad formatted tasks if not texte.startswith("<content>"): texte = cgi.escape(texte, quote=True) texte = f"<content>{texte}" if not texte.endswith("</content>"): texte = f"{texte}</content>" self.content = str(texte) else: self.content = ""
https://github.com/getting-things-gnome/gtg/issues/259
Traceback (most recent call last): File "/home/jeff/gtg/GTG/gtk/editor/taskview.py", line 550, in modified self._detect_tag(buff, local_start, local_end) File "/home/jeff/gtg/GTG/gtk/editor/taskview.py", line 740, in _detect_tag self.add_tag_callback(my_word) File "/home/jeff/gtg/GTG/core/task.py", line 707, in add_tag cgi.escape(tagname), sep, c) AttributeError: module 'cgi' has no attribute 'escape'
AttributeError
def add_tag(self, tagname): "Add a tag to the task and insert '@tag' into the task's content" if self.tag_added(tagname): c = self.content # strip <content>...</content> tags if c.startswith("<content>"): c = c[len("<content>") :] if c.endswith("</content>"): c = c[: -len("</content>")] if not c: # don't need a separator if it's the only text sep = "" elif c.startswith("<tag>"): # if content starts with a tag, make a comma-separated list sep = ", " else: # other text at the beginning, so put the tag on its own line sep = "\n\n" self.content = "<content><tag>%s</tag>%s%s</content>" % ( html.escape(tagname), sep, c, ) # we modify the task internal state, thus we have to call for a # sync self.sync()
def add_tag(self, tagname): "Add a tag to the task and insert '@tag' into the task's content" if self.tag_added(tagname): c = self.content # strip <content>...</content> tags if c.startswith("<content>"): c = c[len("<content>") :] if c.endswith("</content>"): c = c[: -len("</content>")] if not c: # don't need a separator if it's the only text sep = "" elif c.startswith("<tag>"): # if content starts with a tag, make a comma-separated list sep = ", " else: # other text at the beginning, so put the tag on its own line sep = "\n\n" self.content = "<content><tag>%s</tag>%s%s</content>" % ( cgi.escape(tagname), sep, c, ) # we modify the task internal state, thus we have to call for a # sync self.sync()
https://github.com/getting-things-gnome/gtg/issues/259
Traceback (most recent call last): File "/home/jeff/gtg/GTG/gtk/editor/taskview.py", line 550, in modified self._detect_tag(buff, local_start, local_end) File "/home/jeff/gtg/GTG/gtk/editor/taskview.py", line 740, in _detect_tag self.add_tag_callback(my_word) File "/home/jeff/gtg/GTG/core/task.py", line 707, in add_tag cgi.escape(tagname), sep, c) AttributeError: module 'cgi' has no attribute 'escape'
AttributeError
def _get_tasks_from_blocks(task_blocks: Sequence) -> Generator: """Get list of tasks from list made of tasks and nested tasks.""" NESTED_TASK_KEYS = [ "block", "always", "rescue", ] def get_nested_tasks(task: Any) -> Generator[Any, None, None]: for k in NESTED_TASK_KEYS: if task and k in task and task[k]: for subtask in task[k]: yield subtask for task in task_blocks: for sub_task in get_nested_tasks(task): yield sub_task yield task
def _get_tasks_from_blocks(task_blocks: Sequence) -> Generator: """Get list of tasks from list made of tasks and nested tasks.""" NESTED_TASK_KEYS = [ "block", "always", "rescue", ] def get_nested_tasks(task: Any) -> Generator[Any, None, None]: return ( subtask for k in NESTED_TASK_KEYS if task and k in task for subtask in task[k] ) for task in task_blocks: for sub_task in get_nested_tasks(task): yield sub_task yield task
https://github.com/ansible-community/ansible-lint/issues/792
Traceback (most recent call last): File "/Users/ssbarnea/.pyenv/versions/3.8.2/bin/ansible-lint", line 11, in <module> load_entry_point('ansible-lint', 'console_scripts', 'ansible-lint')() File "/Users/ssbarnea/c/os/ansible-lint/lib/ansiblelint/__main__.py", line 94, in main matches.extend(runner.run()) File "/Users/ssbarnea/c/os/ansible-lint/lib/ansiblelint/__init__.py", line 159, in run for child in ansiblelint.utils.find_children(arg, self.playbook_dir): File "/Users/ssbarnea/c/os/ansible-lint/lib/ansiblelint/utils.py", line 195, in find_children for child in _rebind_match_filename(playbook[0], play_children)( File "/Users/ssbarnea/c/os/ansible-lint/lib/ansiblelint/utils.py", line 174, in func_wrapper return func(*args, **kwargs) File "/Users/ssbarnea/c/os/ansible-lint/lib/ansiblelint/utils.py", line 248, in play_children return delegate_map[k](basedir, k, v, parent_type) File "/Users/ssbarnea/c/os/ansible-lint/lib/ansiblelint/utils.py", line 287, in _taskshandlers_children results.extend(_taskshandlers_children(basedir, k, th['block'], parent_type)) File "/Users/ssbarnea/c/os/ansible-lint/lib/ansiblelint/utils.py", line 264, in _taskshandlers_children for th in v: TypeError: 'NoneType' object is not iterable
TypeError
def get_nested_tasks(task: Any) -> Generator[Any, None, None]: for k in NESTED_TASK_KEYS: if task and k in task and task[k]: for subtask in task[k]: yield subtask
def get_nested_tasks(task: Any) -> Generator[Any, None, None]: return ( subtask for k in NESTED_TASK_KEYS if task and k in task for subtask in task[k] )
https://github.com/ansible-community/ansible-lint/issues/792
Traceback (most recent call last): File "/Users/ssbarnea/.pyenv/versions/3.8.2/bin/ansible-lint", line 11, in <module> load_entry_point('ansible-lint', 'console_scripts', 'ansible-lint')() File "/Users/ssbarnea/c/os/ansible-lint/lib/ansiblelint/__main__.py", line 94, in main matches.extend(runner.run()) File "/Users/ssbarnea/c/os/ansible-lint/lib/ansiblelint/__init__.py", line 159, in run for child in ansiblelint.utils.find_children(arg, self.playbook_dir): File "/Users/ssbarnea/c/os/ansible-lint/lib/ansiblelint/utils.py", line 195, in find_children for child in _rebind_match_filename(playbook[0], play_children)( File "/Users/ssbarnea/c/os/ansible-lint/lib/ansiblelint/utils.py", line 174, in func_wrapper return func(*args, **kwargs) File "/Users/ssbarnea/c/os/ansible-lint/lib/ansiblelint/utils.py", line 248, in play_children return delegate_map[k](basedir, k, v, parent_type) File "/Users/ssbarnea/c/os/ansible-lint/lib/ansiblelint/utils.py", line 287, in _taskshandlers_children results.extend(_taskshandlers_children(basedir, k, th['block'], parent_type)) File "/Users/ssbarnea/c/os/ansible-lint/lib/ansiblelint/utils.py", line 264, in _taskshandlers_children for th in v: TypeError: 'NoneType' object is not iterable
TypeError
def _taskshandlers_children(basedir, k, v, parent_type: FileType) -> List: results = [] if v is None: raise MatchError( message="A malformed block was encountered while loading a block.", rule=RuntimeErrorRule, ) for th in v: # ignore empty tasks, `-` if not th: continue with contextlib.suppress(LookupError): children = _get_task_handler_children_for_tasks_or_playbooks( th, basedir, k, parent_type, ) results.append(children) continue if ( "include_role" in th or "import_role" in th ): # lgtm [py/unreachable-statement] th = normalize_task_v2(th) _validate_task_handler_action_for_role(th["action"]) results.extend( _roles_children( basedir, k, [th["action"].get("name")], parent_type, main=th["action"].get("tasks_from", "main"), ) ) continue if "block" not in th: continue results.extend(_taskshandlers_children(basedir, k, th["block"], parent_type)) if "rescue" in th: results.extend( _taskshandlers_children(basedir, k, th["rescue"], parent_type) ) if "always" in th: results.extend( _taskshandlers_children(basedir, k, th["always"], parent_type) ) return results
def _taskshandlers_children(basedir, k, v, parent_type: FileType) -> List: results = [] for th in v: # ignore empty tasks, `-` if not th: continue with contextlib.suppress(LookupError): children = _get_task_handler_children_for_tasks_or_playbooks( th, basedir, k, parent_type, ) results.append(children) continue if ( "include_role" in th or "import_role" in th ): # lgtm [py/unreachable-statement] th = normalize_task_v2(th) _validate_task_handler_action_for_role(th["action"]) results.extend( _roles_children( basedir, k, [th["action"].get("name")], parent_type, main=th["action"].get("tasks_from", "main"), ) ) continue if "block" not in th: continue results.extend(_taskshandlers_children(basedir, k, th["block"], parent_type)) if "rescue" in th: results.extend( _taskshandlers_children(basedir, k, th["rescue"], parent_type) ) if "always" in th: results.extend( _taskshandlers_children(basedir, k, th["always"], parent_type) ) return results
https://github.com/ansible-community/ansible-lint/issues/792
Traceback (most recent call last): File "/Users/ssbarnea/.pyenv/versions/3.8.2/bin/ansible-lint", line 11, in <module> load_entry_point('ansible-lint', 'console_scripts', 'ansible-lint')() File "/Users/ssbarnea/c/os/ansible-lint/lib/ansiblelint/__main__.py", line 94, in main matches.extend(runner.run()) File "/Users/ssbarnea/c/os/ansible-lint/lib/ansiblelint/__init__.py", line 159, in run for child in ansiblelint.utils.find_children(arg, self.playbook_dir): File "/Users/ssbarnea/c/os/ansible-lint/lib/ansiblelint/utils.py", line 195, in find_children for child in _rebind_match_filename(playbook[0], play_children)( File "/Users/ssbarnea/c/os/ansible-lint/lib/ansiblelint/utils.py", line 174, in func_wrapper return func(*args, **kwargs) File "/Users/ssbarnea/c/os/ansible-lint/lib/ansiblelint/utils.py", line 248, in play_children return delegate_map[k](basedir, k, v, parent_type) File "/Users/ssbarnea/c/os/ansible-lint/lib/ansiblelint/utils.py", line 287, in _taskshandlers_children results.extend(_taskshandlers_children(basedir, k, th['block'], parent_type)) File "/Users/ssbarnea/c/os/ansible-lint/lib/ansiblelint/utils.py", line 264, in _taskshandlers_children for th in v: TypeError: 'NoneType' object is not iterable
TypeError
def matchyaml(self, file: dict, text: str) -> List[MatchError]: matches: List[MatchError] = [] if not self.matchplay: return matches yaml = ansiblelint.utils.parse_yaml_linenumbers(text, file["path"]) # yaml returned can be an AnsibleUnicode (a string) when the yaml # file contains a single string. YAML spec allows this but we consider # this an fatal error. if isinstance(yaml, str): return [MatchError(filename=file["path"], rule=LoadingFailureRule())] if not yaml: return matches if isinstance(yaml, dict): yaml = [yaml] yaml = ansiblelint.skip_utils.append_skipped_rules(yaml, text, file["type"]) for play in yaml: # Bug #849 if play is None: continue if self.id in play.get("skipped_rules", ()): continue result = self.matchplay(file, play) if not result: continue if isinstance(result, tuple): result = [result] if not isinstance(result, list): raise TypeError("{} is not a list".format(result)) for section, message, *optional_linenumber in result: linenumber = self._matchplay_linenumber(play, optional_linenumber) matches.append( self.create_matcherror( message=message, linenumber=linenumber, details=str(section), filename=file["path"], ) ) return matches
def matchyaml(self, file: dict, text: str) -> List[MatchError]: matches: List[MatchError] = [] if not self.matchplay: return matches yaml = ansiblelint.utils.parse_yaml_linenumbers(text, file["path"]) # yaml returned can be an AnsibleUnicode (a string) when the yaml # file contains a single string. YAML spec allows this but we consider # this an fatal error. if isinstance(yaml, str): return [MatchError(filename=file["path"], rule=LoadingFailureRule())] if not yaml: return matches if isinstance(yaml, dict): yaml = [yaml] yaml = ansiblelint.skip_utils.append_skipped_rules(yaml, text, file["type"]) for play in yaml: if self.id in play.get("skipped_rules", ()): continue result = self.matchplay(file, play) if not result: continue if isinstance(result, tuple): result = [result] if not isinstance(result, list): raise TypeError("{} is not a list".format(result)) for section, message, *optional_linenumber in result: linenumber = self._matchplay_linenumber(play, optional_linenumber) matches.append( self.create_matcherror( message=message, linenumber=linenumber, details=str(section), filename=file["path"], ) ) return matches
https://github.com/ansible-community/ansible-lint/issues/849
(venv) user@test:~/ansible$ cat test.yml - #debug: # msg: Hello! (venv) user@test:~/ansible$ ansible-lint test.yml -vvv DEBUG Logging initialized to level 10 DEBUG Options: Namespace(colored=True, config_file=None, display_relative_path=True, exclude_paths=[], format='plain', listrules=False, listtags=False, parseable=False, parseable_severity=False, playbook=['test.yml'], quiet=False, rulesdir=[], skip_list=[], tags=[], use_default_rules=False, verbosity=3) DEBUG Loading rules from /home/user/ansible/venv/lib/python3.8/site-packages/ansiblelint/rules Traceback (most recent call last): File "/home/user/ansible/venv/bin/ansible-lint", line 8, in <module> sys.exit(main()) File "/home/user/ansible/venv/lib/python3.8/site-packages/ansiblelint/__main__.py", line 116, in main matches.extend(runner.run()) File "/home/user/ansible/venv/lib/python3.8/site-packages/ansiblelint/runner.py", line 73, in run for child in ansiblelint.utils.find_children(arg, self.playbook_dir): File "/home/user/ansible/venv/lib/python3.8/site-packages/ansiblelint/utils.py", line 159, in find_children items = _playbook_items(playbook_ds) File "/home/user/ansible/venv/lib/python3.8/site-packages/ansiblelint/utils.py", line 134, in _playbook_items return [item for play in pb_data for item in play.items()] File "/home/user/ansible/venv/lib/python3.8/site-packages/ansiblelint/utils.py", line 134, in <listcomp> return [item for play in pb_data for item in play.items()] AttributeError: 'NoneType' object has no attribute 'items'
AttributeError
def _playbook_items(pb_data: dict) -> ItemsView: if isinstance(pb_data, dict): return pb_data.items() elif not pb_data: return [] else: # "if play" prevents failure if the play sequence containes None, # which is weird but currently allowed by Ansible # https://github.com/ansible-community/ansible-lint/issues/849 return [item for play in pb_data if play for item in play.items()]
def _playbook_items(pb_data: dict) -> ItemsView: if isinstance(pb_data, dict): return pb_data.items() elif not pb_data: return [] else: return [item for play in pb_data for item in play.items()]
https://github.com/ansible-community/ansible-lint/issues/849
(venv) user@test:~/ansible$ cat test.yml - #debug: # msg: Hello! (venv) user@test:~/ansible$ ansible-lint test.yml -vvv DEBUG Logging initialized to level 10 DEBUG Options: Namespace(colored=True, config_file=None, display_relative_path=True, exclude_paths=[], format='plain', listrules=False, listtags=False, parseable=False, parseable_severity=False, playbook=['test.yml'], quiet=False, rulesdir=[], skip_list=[], tags=[], use_default_rules=False, verbosity=3) DEBUG Loading rules from /home/user/ansible/venv/lib/python3.8/site-packages/ansiblelint/rules Traceback (most recent call last): File "/home/user/ansible/venv/bin/ansible-lint", line 8, in <module> sys.exit(main()) File "/home/user/ansible/venv/lib/python3.8/site-packages/ansiblelint/__main__.py", line 116, in main matches.extend(runner.run()) File "/home/user/ansible/venv/lib/python3.8/site-packages/ansiblelint/runner.py", line 73, in run for child in ansiblelint.utils.find_children(arg, self.playbook_dir): File "/home/user/ansible/venv/lib/python3.8/site-packages/ansiblelint/utils.py", line 159, in find_children items = _playbook_items(playbook_ds) File "/home/user/ansible/venv/lib/python3.8/site-packages/ansiblelint/utils.py", line 134, in _playbook_items return [item for play in pb_data for item in play.items()] File "/home/user/ansible/venv/lib/python3.8/site-packages/ansiblelint/utils.py", line 134, in <listcomp> return [item for play in pb_data for item in play.items()] AttributeError: 'NoneType' object has no attribute 'items'
AttributeError
def expand_path_vars(path: str) -> str: """Expand the environment or ~ variables in a path string.""" # It may be possible for function to be called with a Path object path = str(path).strip() path = os.path.expanduser(path) path = os.path.expandvars(path) return path
def expand_path_vars(path: str) -> str: """Expand the environment or ~ variables in a path string.""" path = path.strip() path = os.path.expanduser(path) path = os.path.expandvars(path) return path
https://github.com/ansible-community/ansible-lint/issues/969
DEBUG Logging initialized to level 10 DEBUG Options: Namespace(colored=True, config_file=None, display_relative_path=True, exclude_paths=[], format='plain', listrules=False, listtags=False, parseable=False, parseable_severity=False, playbook=['playbook.yml'], quiet=False, rulesdir=[PosixPath('/lint-rules')], skip_list=[], tags=[], use_default_rules=True, verbosity=3) Traceback (most recent call last): File "/usr/local/bin/ansible-lint", line 8, in <module> sys.exit(main()) File "/usr/local/lib/python3.8/site-packages/ansiblelint/__main__.py", line 93, in main rules = RulesCollection(rulesdirs) File "/usr/local/lib/python3.8/site-packages/ansiblelint/rules/__init__.py", line 186, in __init__ self.rulesdirs = ansiblelint.utils.expand_paths_vars(rulesdirs) File "/usr/local/lib/python3.8/site-packages/ansiblelint/utils.py", line 783, in expand_paths_vars paths = [expand_path_vars(p) for p in paths] File "/usr/local/lib/python3.8/site-packages/ansiblelint/utils.py", line 783, in <listcomp> paths = [expand_path_vars(p) for p in paths] File "/usr/local/lib/python3.8/site-packages/ansiblelint/utils.py", line 775, in expand_path_vars path = path.strip() AttributeError: 'PosixPath' object has no attribute 'strip'
AttributeError
def focus_event(self): if self.focus is None: return None else: return self.focus.original_widget
def focus_event(self): return self.focus.original_widget
https://github.com/pimutils/khal/issues/986
Traceback (most recent call last): File "/usr/lib/python3.8/site-packages/khal/ui/__init__.py", line 1348, in start_pane loop.run() File "/usr/lib/python3.8/site-packages/urwid/main_loop.py", line 287, in run self._run() File "/usr/lib/python3.8/site-packages/urwid/main_loop.py", line 385, in _run self.event_loop.run() File "/usr/lib/python3.8/site-packages/urwid/main_loop.py", line 790, in run self._loop() File "/usr/lib/python3.8/site-packages/urwid/main_loop.py", line 827, in _loop self._watch_files[fd]() File "/usr/lib/python3.8/site-packages/urwid/raw_display.py", line 416, in <lambda> wrapper = lambda: self.parse_input( File "/usr/lib/python3.8/site-packages/urwid/raw_display.py", line 515, in parse_input callback(processed, processed_codes) File "/usr/lib/python3.8/site-packages/urwid/main_loop.py", line 412, in _update self.process_input(keys) File "/usr/lib/python3.8/site-packages/urwid/main_loop.py", line 513, in process_input k = self._topmost_widget.keypress(self.screen_size, k) File "/usr/lib/python3.8/site-packages/urwid/wimp.py", line 651, in keypress return self._current_widget.keypress(size, key) File "/usr/lib/python3.8/site-packages/urwid/container.py", line 1135, in keypress return self.body.keypress( (maxcol, remaining), key ) File "/usr/lib/python3.8/site-packages/khal/ui/base.py", line 114, in keypress return super().keypress(size, key) File "/usr/lib/python3.8/site-packages/khal/ui/widgets.py", line 308, in keypress key = super(NextMixin, self).keypress(size, key) File "/usr/lib/python3.8/site-packages/urwid/container.py", line 2316, in keypress key = w.keypress((mc,) + size[1:], key) File "/usr/lib/python3.8/site-packages/khal/ui/__init__.py", line 903, in keypress if self.focus_event: File "/usr/lib/python3.8/site-packages/khal/ui/__init__.py", line 636, in focus_event return self.dlistbox.focus_event File "/usr/lib/python3.8/site-packages/khal/ui/__init__.py", line 258, in focus_event return self.focus.original_widget AttributeError: 'NoneType' object has no attribute 'original_widget'
AttributeError
def config_checks( config, _get_color_from_vdir=get_color_from_vdir, _get_vdir_type=get_vdir_type ): """do some tests on the config we cannot do with configobj's validator""" if len(config["calendars"].keys()) < 1: logger.fatal("Found no calendar section in the config file") raise InvalidSettingsError() config["sqlite"]["path"] = expand_db_path(config["sqlite"]["path"]) if not config["locale"]["default_timezone"]: config["locale"]["default_timezone"] = is_timezone( config["locale"]["default_timezone"] ) if not config["locale"]["local_timezone"]: config["locale"]["local_timezone"] = is_timezone( config["locale"]["local_timezone"] ) # expand calendars with type = discover vdirs_complete = list() vdir_colors_from_config = {} for calendar in list(config["calendars"].keys()): if not isinstance(config["calendars"][calendar], dict): logger.fatal("Invalid config file, probably missing calendar sections") raise InvalidSettingsError if config["calendars"][calendar]["type"] == "discover": logger.debug( "discovering calendars in {}".format( config["calendars"][calendar]["path"] ) ) vdirs = get_all_vdirs(config["calendars"][calendar]["path"]) vdirs_complete += vdirs if "color" in config["calendars"][calendar]: for vdir in vdirs: vdir_colors_from_config[vdir] = config["calendars"][calendar][ "color" ] config["calendars"].pop(calendar) for vdir in sorted(vdirs_complete): calendar = { "path": vdir, "color": _get_color_from_vdir(vdir), "type": _get_vdir_type(vdir), "readonly": False, "priority": 10, } # get color from config if not defined in vdir if calendar["color"] is None and vdir in vdir_colors_from_config: logger.debug("using collection's color for {}".format(vdir)) calendar["color"] = vdir_colors_from_config[vdir] name = get_unique_name(vdir, config["calendars"].keys()) config["calendars"][name] = calendar test_default_calendar(config) for calendar in config["calendars"]: if config["calendars"][calendar]["type"] == "birthdays": config["calendars"][calendar]["readonly"] = True if config["calendars"][calendar]["color"] == "auto": config["calendars"][calendar]["color"] = _get_color_from_vdir( config["calendars"][calendar]["path"] )
def config_checks( config, _get_color_from_vdir=get_color_from_vdir, _get_vdir_type=get_vdir_type ): """do some tests on the config we cannot do with configobj's validator""" if len(config["calendars"].keys()) < 1: logger.fatal("Found no calendar section in the config file") raise InvalidSettingsError() config["sqlite"]["path"] = expand_db_path(config["sqlite"]["path"]) if not config["locale"]["default_timezone"]: config["locale"]["default_timezone"] = is_timezone( config["locale"]["default_timezone"] ) if not config["locale"]["local_timezone"]: config["locale"]["local_timezone"] = is_timezone( config["locale"]["local_timezone"] ) # expand calendars with type = discover vdirs_complete = list() vdir_colors_from_config = {} for calendar in list(config["calendars"].keys()): if not isinstance(config["calendars"][calendar], dict): logger.fatal("Invalid config file, probably missing calendar sections") raise InvalidSettingsError if config["calendars"][calendar]["type"] == "discover": logger.debug( "discovering calendars in {}".format( config["calendars"][calendar]["path"] ) ) vdirs = get_all_vdirs(config["calendars"][calendar]["path"]) vdirs_complete += vdirs if "color" in config["calendars"][calendar]: for vdir in vdirs: vdir_colors_from_config[vdir] = config["calendars"][calendar][ "color" ] config["calendars"].pop(calendar) for vdir in sorted(vdirs_complete): calendar = { "path": vdir, "color": _get_color_from_vdir(vdir), "type": _get_vdir_type(vdir), "readonly": False, } # get color from config if not defined in vdir if calendar["color"] is None and vdir in vdir_colors_from_config: logger.debug("using collection's color for {}".format(vdir)) calendar["color"] = vdir_colors_from_config[vdir] name = get_unique_name(vdir, config["calendars"].keys()) config["calendars"][name] = calendar test_default_calendar(config) for calendar in config["calendars"]: if config["calendars"][calendar]["type"] == "birthdays": config["calendars"][calendar]["readonly"] = True if config["calendars"][calendar]["color"] == "auto": config["calendars"][calendar]["color"] = _get_color_from_vdir( config["calendars"][calendar]["path"] )
https://github.com/pimutils/khal/issues/856
Traceback (most recent call last): File "/home/linuxbrew/.linuxbrew/bin/ikhal", line 10, in <module> sys.exit(main_ikhal()) File "/home/linuxbrew/.linuxbrew/lib/python3.7/site-packages/click/core.py", line 764, in __call__ return self.main(*args, **kwargs) File "/home/linuxbrew/.linuxbrew/lib/python3.7/site-packages/click/core.py", line 717, in main rv = self.invoke(ctx) File "/home/linuxbrew/.linuxbrew/lib/python3.7/site-packages/click/core.py", line 956, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/linuxbrew/.linuxbrew/lib/python3.7/site-packages/click/core.py", line 555, in invoke return callback(*args, **kwargs) File "/home/linuxbrew/.linuxbrew/lib/python3.7/site-packages/click/decorators.py", line 17, in new_func return f(get_current_context(), *args, **kwargs) File "/home/linuxbrew/.linuxbrew/lib/python3.7/site-packages/khal/cli.py", line 481, in interactive_cli multi_calendar_select(ctx, include_calendar, exclude_calendar) File "/home/linuxbrew/.linuxbrew/lib/python3.7/site-packages/khal/cli.py", line 165, in build_collection 'priority': cal['priority'], File "/home/linuxbrew/.linuxbrew/lib/python3.7/site-packages/configobj-5.0.6-py3.7.egg/configobj.py", line 554, in __getitem__ KeyError: 'priority'
KeyError
def __init__(self, rrule, conf, startdt): self._conf = conf self._startdt = startdt self._rrule = rrule self.repeat = bool(rrule) self._allow_edit = not self.repeat or self.check_understood_rrule(rrule) self.repeat_box = urwid.CheckBox( "Repeat: ", state=self.repeat, on_state_change=self.check_repeat, ) if "UNTIL" in self._rrule: self._until = "Until" elif "COUNT" in self._rrule: self._until = "Repetitions" else: self._until = "Forever" recurrence = self._rrule["freq"][0].lower() if self._rrule else "weekly" self.recurrence_choice = Choice( ["daily", "weekly", "monthly", "yearly"], recurrence, callback=self.rebuild, ) self.interval_edit = PositiveIntEdit( caption="every:", edit_text=str(self._rrule.get("INTERVAL", [1])[0]), ) self.until_choice = Choice( ["Forever", "Until", "Repetitions"], self._until, callback=self.rebuild, ) count = str(self._rrule.get("COUNT", [1])[0]) self.repetitions_edit = PositiveIntEdit(edit_text=count) until = self._rrule.get("UNTIL", [None])[0] if until is None and isinstance(self._startdt, datetime): until = self._startdt.date() elif until is None: until = self._startdt if isinstance(until, datetime): until = until.date() self.until_edit = DateEdit( until, self._conf["locale"]["longdateformat"], lambda _: None, self._conf["locale"]["weeknumbers"], self._conf["locale"]["firstweekday"], ) self._rebuild_weekday_checks() self._rebuild_monthly_choice() self._pile = pile = NPile([urwid.Text("")]) urwid.WidgetWrap.__init__(self, pile) self.rebuild()
def __init__(self, rrule, conf, startdt): self._conf = conf self._startdt = startdt self._rrule = rrule self.repeat = bool(rrule) self._allow_edit = not self.repeat or self.check_understood_rrule(rrule) self.repeat_box = urwid.CheckBox( "Repeat: ", state=self.repeat, on_state_change=self.check_repeat, ) if "UNTIL" in self._rrule: self._until = "Until" elif "COUNT" in self._rrule: self._until = "Repetitions" else: self._until = "Forever" recurrence = self._rrule["freq"][0].lower() if self._rrule else "weekly" self.recurrence_choice = Choice( ["daily", "weekly", "monthly", "yearly"], recurrence, callback=self.rebuild, ) self.interval_edit = PositiveIntEdit( caption="every:", edit_text=str(self._rrule.get("INTERVAL", [1])[0]), ) self.until_choice = Choice( ["Forever", "Until", "Repetitions"], self._until, callback=self.rebuild, ) count = str(self._rrule.get("COUNT", [1])[0]) self.repetitions_edit = PositiveIntEdit(edit_text=count) until = self._rrule.get("UNTIL", [None])[0] if until is None and isinstance(self._startdt, datetime): until = self._startdt.date() elif until is None: until = self._startdt if isinstance(until, datetime): until = datetime.date() self.until_edit = DateEdit( until, self._conf["locale"]["longdateformat"], lambda _: None, self._conf["locale"]["weeknumbers"], self._conf["locale"]["firstweekday"], ) self._rebuild_weekday_checks() self._rebuild_monthly_choice() self._pile = pile = NPile([urwid.Text("")]) urwid.WidgetWrap.__init__(self, pile) self.rebuild()
https://github.com/pimutils/khal/issues/707
Traceback (most recent call last):i Walker (*1979) ⟳ File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/khal/ui/__init__.py", line 1300, in start_pane loop.run() File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/urwid/main_loop.py", line 278, in run self._run() File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/urwid/main_loop.py", line 376, in _run self.event_loop.run() File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/urwid/main_loop.py", line 682, in run self._loop() File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/urwid/main_loop.py", line 719, in _loop self._watch_files[fd]() File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/urwid/raw_display.py", line 393, in <lambda> event_loop, callback, self.get_available_raw_input()) File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/urwid/raw_display.py", line 493, in parse_input callback(processed, processed_codes) File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/urwid/main_loop.py", line 403, in _update self.process_input(keys) File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/urwid/main_loop.py", line 503, in process_input k = self._topmost_widget.keypress(self.screen_size, k) File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/urwid/wimp.py", line 643, in keypress return self._current_widget.keypress(size, key) File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/urwid/container.py", line 1128, in keypress return self.body.keypress( (maxcol, remaining), key File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/khal/ui/__init__.py", line 1106, in keypress return super().keypress(size, key) File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/khal/ui/base.py", line 82, in keypress return super().keypress(size, key) File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/khal/ui/widgets.py", line 308, in keypress key = super(NextMixin, self).keypress(size, key) File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/urwid/container.py", line 2269, in keypress key = w.keypress((mc,) + size[1:], key) File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/khal/ui/__init__.py", line 919, in keypress self.edit(self.focus_event.event) File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/khal/ui/__init__.py", line 756, in edit editor = EventEditor(self.pane, event, update_colors, always_save=always_save) File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/khal/ui/editor.py", line 342, in __init__ self.event.recurobject, self._conf, event.start_local, File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/khal/ui/editor.py", line 569, in __init__ until = datetime.date() TypeError: descriptor 'date' of 'datetime.datetime' object needs an argument
TypeError
def fromVEvents(cls, events_list, ref=None, **kwargs): """ :type events: list """ assert isinstance(events_list, list) vevents = dict() for event in events_list: if "RECURRENCE-ID" in event: if invalid_timezone(event["RECURRENCE-ID"]): default_timezone = kwargs["locale"]["default_timezone"] recur_id = default_timezone.localize(event["RECURRENCE-ID"].dt) ident = str(to_unix_time(recur_id)) else: ident = str(to_unix_time(event["RECURRENCE-ID"].dt)) vevents[ident] = event else: vevents["PROTO"] = event if ref is None: ref = "PROTO" try: if type(vevents[ref]["DTSTART"].dt) != type(vevents[ref]["DTEND"].dt): # flake8: noqa raise ValueError( "DTSTART and DTEND should be of the same type (datetime or date)" ) except KeyError: pass if kwargs.get("start"): instcls = cls._get_type_from_date(kwargs.get("start")) else: instcls = cls._get_type_from_vDDD(vevents[ref]["DTSTART"]) return instcls(vevents, ref=ref, **kwargs)
def fromVEvents(cls, events_list, ref=None, **kwargs): """ :type events: list """ assert isinstance(events_list, list) vevents = dict() if len(events_list) == 1: vevents["PROTO"] = events_list[0] # TODO set mutable = False else: for event in events_list: if "RECURRENCE-ID" in event: if invalid_timezone(event["RECURRENCE-ID"]): default_timezone = kwargs["locale"]["default_timezone"] recur_id = default_timezone.localize(event["RECURRENCE-ID"].dt) ident = str(to_unix_time(recur_id)) else: ident = str(to_unix_time(event["RECURRENCE-ID"].dt)) vevents[ident] = event else: vevents["PROTO"] = event if ref is None: ref = "PROTO" try: if type(vevents[ref]["DTSTART"].dt) != type(vevents[ref]["DTEND"].dt): # flake8: noqa raise ValueError( "DTSTART and DTEND should be of the same type (datetime or date)" ) except KeyError: pass if kwargs.get("start"): instcls = cls._get_type_from_date(kwargs.get("start")) else: instcls = cls._get_type_from_vDDD(vevents[ref]["DTSTART"]) return instcls(vevents, ref=ref, **kwargs)
https://github.com/pimutils/khal/issues/608
$ khal critical: Cannot understand event 2233f40b-9d80-49ff-aac0-01c2f957fc9f.ics from calendar shiftgig, critical: you might want tofile an issue at https://github.com/pimutils/khal/issues Traceback (most recent call last): File "/usr/bin/khal", line 11, in <module> load_entry_point('khal==0.9.4.dev26+ng93e6861', 'console_scripts', 'khal')() File "/usr/lib/python3.6/site-packages/click/core.py", line 722, in __call__ return self.main(*args, **kwargs) File "/usr/lib/python3.6/site-packages/click/core.py", line 697, in main rv = self.invoke(ctx) File "/usr/lib/python3.6/site-packages/click/core.py", line 1043, in invoke return Command.invoke(self, ctx) File "/usr/lib/python3.6/site-packages/click/core.py", line 895, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/lib/python3.6/site-packages/click/core.py", line 535, in invoke return callback(*args, **kwargs) File "/usr/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func return f(get_current_context(), *args, **kwargs) File "/usr/lib/python3.6/site-packages/khal/cli.py", line 250, in cli ctx.invoke(cli.commands[command]) File "/usr/lib/python3.6/site-packages/click/core.py", line 535, in invoke return callback(*args, **kwargs) File "/usr/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func return f(get_current_context(), *args, **kwargs) File "/usr/lib/python3.6/site-packages/khal/cli.py", line 289, in calendar env={"calendars": ctx.obj['conf']['calendars']} File "/usr/lib/python3.6/site-packages/khal/controllers.py", line 105, in calendar env=env, File "/usr/lib/python3.6/site-packages/khal/controllers.py", line 264, in khal_list width=width, File "/usr/lib/python3.6/site-packages/khal/controllers.py", line 182, in get_events_between events = sorted(collection.get_localized(start_local, end_local)) File "/usr/lib/python3.6/site-packages/khal/khalendar/khalendar.py", line 148, in <genexpr> return (self._cover_event(event) for event in events) File "/usr/lib/python3.6/site-packages/khal/khalendar/backend.py", line 485, in get_localized yield self.construct_event(item, href, start, end, ref, etag, calendar, dtype) File "/usr/lib/python3.6/site-packages/khal/khalendar/backend.py", line 564, in construct_event ref=ref, File "/usr/lib/python3.6/site-packages/khal/khalendar/event.py", line 155, in fromString return cls.fromVEvents(events, ref, **kwargs) File "/usr/lib/python3.6/site-packages/khal/khalendar/event.py", line 149, in fromVEvents return instcls(vevents, ref=ref, **kwargs) File "/usr/lib/python3.6/site-packages/khal/khalendar/event.py", line 634, in __init__ starttz = getattr(self._vevents[self.ref]['DTSTART'].dt, 'tzinfo', None) KeyError: '1490803200'
KeyError
def expand(vevent, href=""): """ Constructs a list of start and end dates for all recurring instances of the event defined in vevent. It considers RRULE as well as RDATE and EXDATE properties. In case of unsupported recursion rules an UnsupportedRecurrence exception is thrown. If the timezone defined in vevent is not understood by icalendar, default_tz is used. :param vevent: vevent to be expanded :type vevent: icalendar.cal.Event :param href: the href of the vevent, used for more informative logging and nothing else :type href: str :returns: list of start and end (date)times of the expanded event :rtype: list(tuple(datetime, datetime)) """ # we do this now and than never care about the "real" end time again if "DURATION" in vevent: duration = vevent["DURATION"].dt else: duration = vevent["DTEND"].dt - vevent["DTSTART"].dt events_tz = getattr(vevent["DTSTART"].dt, "tzinfo", None) allday = not isinstance(vevent["DTSTART"].dt, datetime) def sanitize_datetime(date): if allday and isinstance(date, datetime): date = date.date() if events_tz is not None: date = events_tz.localize(date) return date rrule_param = vevent.get("RRULE") if rrule_param is not None: vevent = sanitize_rrule(vevent) # dst causes problem while expanding the rrule, therefore we transform # everything to naive datetime objects and transform back after # expanding # See https://github.com/dateutil/dateutil/issues/102 dtstart = vevent["DTSTART"].dt if events_tz: dtstart = dtstart.replace(tzinfo=None) rrule = dateutil.rrule.rrulestr(rrule_param.to_ical().decode(), dtstart=dtstart) if rrule._until is None: # rrule really doesn't like to calculate all recurrences until # eternity, so we only do it until 2037, because a) I'm not sure # if python can deal with larger datetime values yet and b) pytz # doesn't know any larger transition times rrule._until = datetime(2037, 12, 31) elif getattr(rrule._until, "tzinfo", None): rrule._until = rrule._until.astimezone(events_tz).replace(tzinfo=None) rrule = map(sanitize_datetime, rrule) logger.debug( "calculating recurrence dates for {0}, this might take some time.".format( href ) ) # RRULE and RDATE may specify the same date twice, it is recommended by # the RFC to consider this as only one instance dtstartl = set(rrule) if not dtstartl: raise UnsupportedRecurrence() else: dtstartl = {vevent["DTSTART"].dt} def get_dates(vevent, key): # TODO replace with get_all_properties dates = vevent.get(key) if dates is None: return if not isinstance(dates, list): dates = [dates] dates = (leaf.dt for tree in dates for leaf in tree.dts) dates = localize_strip_tz(dates, events_tz) return map(sanitize_datetime, dates) # include explicitly specified recursion dates dtstartl.update(get_dates(vevent, "RDATE") or ()) # remove excluded dates for date in get_dates(vevent, "EXDATE") or (): try: dtstartl.remove(date) except KeyError: logger.warning( "In event {}, excluded instance starting at {} not found, " "event might be invalid.".format(href, date) ) dtstartend = [(start, start + duration) for start in dtstartl] # not necessary, but I prefer deterministic output dtstartend.sort() return dtstartend
def expand(vevent, href=""): """ Constructs a list of start and end dates for all recurring instances of the event defined in vevent. It considers RRULE as well as RDATE and EXDATE properties. In case of unsupported recursion rules an UnsupportedRecurrence exception is thrown. If the timezone defined in vevent is not understood by icalendar, default_tz is used. :param vevent: vevent to be expanded :type vevent: icalendar.cal.Event :param href: the href of the vevent, used for more informative logging and nothing else :type href: str :returns: list of start and end (date)times of the expanded event :rtype: list(tuple(datetime, datetime)) """ # we do this now and than never care about the "real" end time again if "DURATION" in vevent: duration = vevent["DURATION"].dt else: duration = vevent["DTEND"].dt - vevent["DTSTART"].dt events_tz = getattr(vevent["DTSTART"].dt, "tzinfo", None) allday = not isinstance(vevent["DTSTART"].dt, datetime) def sanitize_datetime(date): if allday and isinstance(date, datetime): date = date.date() if events_tz is not None: date = events_tz.localize(date) return date rrule_param = vevent.get("RRULE") if rrule_param is not None: vevent = sanitize_rrule(vevent) # dst causes problem while expanding the rrule, therefore we transform # everything to naive datetime objects and transform back after # expanding # See https://github.com/dateutil/dateutil/issues/102 dtstart = vevent["DTSTART"].dt if events_tz: dtstart = dtstart.replace(tzinfo=None) rrule = dateutil.rrule.rrulestr(rrule_param.to_ical().decode(), dtstart=dtstart) if rrule._until is None: # rrule really doesn't like to calculate all recurrences until # eternity, so we only do it until 2037, because a) I'm not sure # if python can deal with larger datetime values yet and b) pytz # doesn't know any larger transition times rrule._until = datetime(2037, 12, 31) elif getattr(rrule._until, "tzinfo", None): rrule._until = rrule._until.astimezone(events_tz).replace(tzinfo=None) rrule = map(sanitize_datetime, rrule) logger.debug( "calculating recurrence dates for {0}, this might take some time.".format( href ) ) # RRULE and RDATE may specify the same date twice, it is recommended by # the RFC to consider this as only one instance dtstartl = set(rrule) if not dtstartl: raise UnsupportedRecurrence() else: dtstartl = {vevent["DTSTART"].dt} def get_dates(vevent, key): dates = vevent.get(key) if dates is None: return if not isinstance(dates, list): dates = [dates] dates = (leaf.dt for tree in dates for leaf in tree.dts) dates = localize_strip_tz(dates, events_tz) return map(sanitize_datetime, dates) # include explicitly specified recursion dates dtstartl.update(get_dates(vevent, "RDATE") or ()) # remove excluded dates for date in get_dates(vevent, "EXDATE") or (): try: dtstartl.remove(date) except KeyError: logger.warning( "In event {}, excluded instance starting at {} not found, " "event might be invalid.".format(href, date) ) dtstartend = [(start, start + duration) for start in dtstartl] # not necessary, but I prefer deterministic output dtstartend.sort() return dtstartend
https://github.com/pimutils/khal/issues/641
Traceback (most recent call last): File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/ui/__init__.py", line 1296, in start_pane loop.run() File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/main_loop.py", line 278, in run self._run() File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/main_loop.py", line 376, in _run self.event_loop.run() File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/main_loop.py", line 682, in run self._loop() File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/main_loop.py", line 719, in _loop self._watch_files[fd]() File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/raw_display.py", line 393, in <lambda> event_loop, callback, self.get_available_raw_input()) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/raw_display.py", line 493, in parse_input callback(processed, processed_codes) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/main_loop.py", line 403, in _update self.process_input(keys) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/main_loop.py", line 509, in process_input something_handled |= bool(self.unhandled_input(k)) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/main_loop.py", line 555, in unhandled_input return self._unhandled_input(input) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/ui/base.py", line 162, in on_key_press self.backtrack() File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/ui/base.py", line 147, in backtrack cb(data) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/ui/__init__.py", line 1095, in cleanup event.delete_instance(rec_id) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/khalendar/event.py", line 602, in delete_instance delete_instance(self._vevents['PROTO'], instance) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/khalendar/utils.py", line 327, in delete_instance _add_exdate(vevent, instance) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/khalendar/utils.py", line 292, in _add_exdate exdates.append(dates_from_exdate(vddlist)) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/khalendar/utils.py", line 282, in dates_from_exdate return [dts.dt for dts in vevent['EXDATE'].dts] AttributeError: 'list' object has no attribute 'dts'
AttributeError
def get_dates(vevent, key): # TODO replace with get_all_properties dates = vevent.get(key) if dates is None: return if not isinstance(dates, list): dates = [dates] dates = (leaf.dt for tree in dates for leaf in tree.dts) dates = localize_strip_tz(dates, events_tz) return map(sanitize_datetime, dates)
def get_dates(vevent, key): dates = vevent.get(key) if dates is None: return if not isinstance(dates, list): dates = [dates] dates = (leaf.dt for tree in dates for leaf in tree.dts) dates = localize_strip_tz(dates, events_tz) return map(sanitize_datetime, dates)
https://github.com/pimutils/khal/issues/641
Traceback (most recent call last): File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/ui/__init__.py", line 1296, in start_pane loop.run() File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/main_loop.py", line 278, in run self._run() File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/main_loop.py", line 376, in _run self.event_loop.run() File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/main_loop.py", line 682, in run self._loop() File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/main_loop.py", line 719, in _loop self._watch_files[fd]() File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/raw_display.py", line 393, in <lambda> event_loop, callback, self.get_available_raw_input()) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/raw_display.py", line 493, in parse_input callback(processed, processed_codes) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/main_loop.py", line 403, in _update self.process_input(keys) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/main_loop.py", line 509, in process_input something_handled |= bool(self.unhandled_input(k)) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/main_loop.py", line 555, in unhandled_input return self._unhandled_input(input) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/ui/base.py", line 162, in on_key_press self.backtrack() File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/ui/base.py", line 147, in backtrack cb(data) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/ui/__init__.py", line 1095, in cleanup event.delete_instance(rec_id) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/khalendar/event.py", line 602, in delete_instance delete_instance(self._vevents['PROTO'], instance) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/khalendar/utils.py", line 327, in delete_instance _add_exdate(vevent, instance) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/khalendar/utils.py", line 292, in _add_exdate exdates.append(dates_from_exdate(vddlist)) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/khalendar/utils.py", line 282, in dates_from_exdate return [dts.dt for dts in vevent['EXDATE'].dts] AttributeError: 'list' object has no attribute 'dts'
AttributeError
def delete_instance(vevent, instance): """remove a recurrence instance from a VEVENT's RRDATE list or add it to the EXDATE list :type vevent: icalendar.cal.Event :type instance: datetime.datetime """ # TODO check where this instance is coming from and only call the # appropriate function if "RRULE" in vevent: exdates = _get_all_properties(vevent, "EXDATE") exdates += [instance] vevent.pop("EXDATE") vevent.add("EXDATE", exdates) if "RDATE" in vevent: rdates = [ one for one in _get_all_properties(vevent, "RDATE") if one != instance ] vevent.pop("RDATE") if rdates != []: vevent.add("RDATE", rdates)
def delete_instance(vevent, instance): """remove a recurrence instance from a VEVENT's RRDATE list :type vevent: icalendar.cal.Event :type instance: datetime.datetime """ if "RDATE" in vevent and "RRULE" in vevent: # TODO check where this instance is coming from and only call the # appropriate function _add_exdate(vevent, instance) _remove_instance(vevent, instance) elif "RRULE" in vevent: _add_exdate(vevent, instance) elif "RDATE" in vevent: _remove_instance(vevent, instance)
https://github.com/pimutils/khal/issues/641
Traceback (most recent call last): File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/ui/__init__.py", line 1296, in start_pane loop.run() File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/main_loop.py", line 278, in run self._run() File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/main_loop.py", line 376, in _run self.event_loop.run() File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/main_loop.py", line 682, in run self._loop() File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/main_loop.py", line 719, in _loop self._watch_files[fd]() File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/raw_display.py", line 393, in <lambda> event_loop, callback, self.get_available_raw_input()) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/raw_display.py", line 493, in parse_input callback(processed, processed_codes) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/main_loop.py", line 403, in _update self.process_input(keys) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/main_loop.py", line 509, in process_input something_handled |= bool(self.unhandled_input(k)) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/urwid/main_loop.py", line 555, in unhandled_input return self._unhandled_input(input) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/ui/base.py", line 162, in on_key_press self.backtrack() File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/ui/base.py", line 147, in backtrack cb(data) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/ui/__init__.py", line 1095, in cleanup event.delete_instance(rec_id) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/khalendar/event.py", line 602, in delete_instance delete_instance(self._vevents['PROTO'], instance) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/khalendar/utils.py", line 327, in delete_instance _add_exdate(vevent, instance) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/khalendar/utils.py", line 292, in _add_exdate exdates.append(dates_from_exdate(vddlist)) File "/usr/local/Cellar/khal/0.9.5/libexec/lib/python3.6/site-packages/khal/khalendar/utils.py", line 282, in dates_from_exdate return [dts.dt for dts in vevent['EXDATE'].dts] AttributeError: 'list' object has no attribute 'dts'
AttributeError
def check_understood_rrule(rrule): """test if we can reproduce `rrule`.""" keys = set(rrule.keys()) freq = rrule.get("FREQ", [None])[0] unsupported_rrule_parts = { "BYSECOND", "BYMINUTE", "BYHOUR", "BYYEARDAY", "BYWEEKNO", "BYMONTH", "BYSETPOS", } if keys.intersection(unsupported_rrule_parts): return False if len(rrule.get("BYMONTHDAY", [1])) > 1: return False # we don't support negative BYMONTHDAY numbers # don't need to check whole list, we only support one monthday anyway if rrule.get("BYMONTHDAY", [1])[0] < 1: return False if rrule.get("BYDAY", ["1"])[0][0] == "-": return False if freq not in ["DAILY", "WEEKLY", "MONTHLY", "YEARLY"]: return False if "BYDAY" in keys and freq == "YEARLY": return False return True
def check_understood_rrule(rrule): """test if we can reproduce `rrule`.""" keys = set(rrule.keys()) freq = rrule.get("FREQ", [None])[0] unsupported_rrule_parts = { "BYSECOND", "BYMINUTE", "BYHOUR", "BYYEARDAY", "BYWEEKNO", "BYMONTH", "BYSETPOS", } if keys.intersection(unsupported_rrule_parts): return False # we don't support negative BYMONTHDAY numbers if rrule.get("BYMONTHDAY", ["1"])[0][0] == "-": return False if rrule.get("BYDAY", ["1"])[0][0] == "-": return False if freq not in ["DAILY", "WEEKLY", "MONTHLY", "YEARLY"]: return False if "BYDAY" in keys and freq == "YEARLY": return False return True
https://github.com/pimutils/khal/issues/643
$ ikhal Traceback (most recent call last): File "/usr/lib/python3/dist-packages/khal/ui/__init__.py", line 1296, in start_pane loop.run() File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 278, in run self._run() File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 376, in _run self.event_loop.run() File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 682, in run self._loop() File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 719, in _loop self._watch_files[fd]() File "/usr/lib/python3/dist-packages/urwid/raw_display.py", line 393, in <lambda> event_loop, callback, self.get_available_raw_input()) File "/usr/lib/python3/dist-packages/urwid/raw_display.py", line 493, in parse_input callback(processed, processed_codes) File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 403, in _update self.process_input(keys) File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 503, in process_input k = self._topmost_widget.keypress(self.screen_size, k) File "/usr/lib/python3/dist-packages/urwid/wimp.py", line 643, in keypress return self._current_widget.keypress(size, key) File "/usr/lib/python3/dist-packages/urwid/container.py", line 1128, in keypress return self.body.keypress( (maxcol, remaining), key ) File "/usr/lib/python3/dist-packages/khal/ui/__init__.py", line 1102, in keypress return super().keypress(size, key) File "/usr/lib/python3/dist-packages/khal/ui/base.py", line 82, in keypress return super().keypress(size, key) File "/usr/lib/python3/dist-packages/khal/ui/widgets.py", line 308, in keypress key = super(NextMixin, self).keypress(size, key) File "/usr/lib/python3/dist-packages/urwid/container.py", line 2269, in keypress key = w.keypress((mc,) + size[1:], key) File "/usr/lib/python3/dist-packages/khal/ui/__init__.py", line 915, in keypress self.edit(self.focus_event.event) File "/usr/lib/python3/dist-packages/khal/ui/__init__.py", line 752, in edit editor = EventEditor(self.pane, event, update_colors, always_save=always_save) File "/usr/lib/python3/dist-packages/khal/ui/editor.py", line 342, in __init__ self.event.recurobject, self._conf, event.start_local, File "/usr/lib/python3/dist-packages/khal/ui/editor.py", line 533, in __init__ self._allow_edit = not self.repeat or self.check_understood_rrule(rrule) File "/usr/lib/python3/dist-packages/khal/ui/editor.py", line 620, in check_understood_rrule if rrule.get('BYMONTHDAY', ['1'])[0][0] == '-': TypeError: 'vInt' object does not support indexing
TypeError
def guessrangefstr(daterange, locale, default_timedelta=None, adjust_reasonably=False): """parses a range string :param daterange: date1 [date2 | timedelta] :type daterange: str or list :param locale: :rtype: (datetime, datetime, bool) """ range_list = daterange if isinstance(daterange, str): range_list = daterange.split(" ") try: if default_timedelta is None or len(default_timedelta) == 0: default_timedelta = None else: default_timedelta = guesstimedeltafstr(default_timedelta) except ValueError: default_timedelta = None for i in reversed(range(1, len(range_list) + 1)): start = " ".join(range_list[:i]) end = " ".join(range_list[i:]) allday = False try: # figuring out start if len(start) == 0: start = datetime_fillin(end=False) elif start.lower() == "week": today_weekday = datetime.today().weekday() start = datetime.today() - timedelta( days=(today_weekday - locale["firstweekday"]) ) end = start + timedelta(days=7) return start, end, True else: split = start.split(" ") start, allday = guessdatetimefstr(split, locale) if len(split) != 0: continue # and end if len(end) == 0: if default_timedelta is not None: end = start + default_timedelta else: end = datetime_fillin(day=start) elif end.lower() == "eod": end = datetime_fillin(day=start) elif end.lower() == "week": start -= timedelta(days=(start.weekday() - locale["firstweekday"])) end = start + timedelta(days=7) else: try: delta = guesstimedeltafstr(end) end = start + delta except ValueError: split = end.split(" ") end, end_allday = guessdatetimefstr( split, locale, default_day=start.date() ) if len(split) != 0: continue end = datetime_fillin(end) if adjust_reasonably: if allday: # TODO move out of here, this is an icalendar peculiarity end += timedelta(days=1) # test if end's year is this year, but start's year is not today = datetime.today() if end.year == today.year and start.year != today.year: end = datetime(start.year, *end.timetuple()[1:6]) if end < start: end = datetime(end.year + 1, *end.timetuple()[1:6]) if end < start: end = datetime(*start.timetuple()[0:3] + end.timetuple()[3:5]) if end < start: end = end + timedelta(days=1) return start, end, allday except ValueError: pass raise ValueError("Could not parse `{}` as a daterange".format(daterange))
def guessrangefstr(daterange, locale, default_timedelta=None, adjust_reasonably=False): """parses a range string :param daterange: date1 [date2 | timedelta] :type daterange: str or list :param locale: :rtype: (datetime, datetime, bool) """ range_list = daterange if isinstance(daterange, str): range_list = daterange.split(" ") try: if default_timedelta is None or len(default_timedelta) == 0: default_timedelta = None else: default_timedelta = guesstimedeltafstr(default_timedelta) except ValueError: default_timedelta = None for i in reversed(range(1, len(range_list) + 1)): start = " ".join(range_list[:i]) end = " ".join(range_list[i:]) allday = False try: # figuring out start if len(start) == 0: start = datetime_fillin(end=False) elif start.lower() == "week": today_weekday = datetime.today().weekday() start = datetime.today() - timedelta( days=(today_weekday - locale["firstweekday"]) ) end = start + timedelta(days=7) else: split = start.split(" ") start, allday = guessdatetimefstr(split, locale) if len(split) != 0: continue # and end if len(end) == 0: if default_timedelta is not None: end = start + default_timedelta else: end = datetime_fillin(day=start) elif end.lower() == "eod": end = datetime_fillin(day=start) elif end.lower() == "week": start -= timedelta(days=(start.weekday() - locale["firstweekday"])) end = start + timedelta(days=7) else: try: delta = guesstimedeltafstr(end) end = start + delta except ValueError: split = end.split(" ") end, end_allday = guessdatetimefstr( split, locale, default_day=start.date() ) if len(split) != 0: continue end = datetime_fillin(end) if adjust_reasonably: if allday: # TODO move out of here, this is an icalendar peculiarity end += timedelta(days=1) # test if end's year is this year, but start's year is not today = datetime.today() if end.year == today.year and start.year != today.year: end = datetime(start.year, *end.timetuple()[1:6]) if end < start: end = datetime(end.year + 1, *end.timetuple()[1:6]) if end < start: end = datetime(*start.timetuple()[0:3] + end.timetuple()[3:5]) if end < start: end = end + timedelta(days=1) return start, end, allday except ValueError: pass raise ValueError("Could not parse `{}` as a daterange".format(daterange))
https://github.com/pimutils/khal/issues/490
Traceback (most recent call last): File "/home/untitaker/.local/bin/khal", line 9, in <module> load_entry_point('khal', 'console_scripts', 'khal')() File "/home/untitaker/projects/click/click/core.py", line 716, in __call__ return self.main(*args, **kwargs) File "/home/untitaker/projects/click/click/core.py", line 696, in main rv = self.invoke(ctx) File "/home/untitaker/projects/click/click/core.py", line 1065, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/untitaker/projects/click/click/core.py", line 892, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/untitaker/projects/click/click/core.py", line 534, in invoke return callback(*args, **kwargs) File "/home/untitaker/projects/click/click/decorators.py", line 17, in new_func return f(get_current_context(), *args, **kwargs) File "/home/untitaker/projects/khal/khal/cli.py", line 315, in klist env={"calendars": ctx.obj['conf']['calendars']} File "/home/untitaker/projects/khal/khal/controllers.py", line 262, in khal_list start, end = start_end_from_daterange(daterange, conf['locale'], td) File "/home/untitaker/projects/khal/khal/controllers.py", line 144, in start_end_from_daterange daterange, locale, default_timedelta=default_timedelta) File "/home/untitaker/projects/khal/khal/aux.py", line 350, in guessrangefstr if len(end) == 0: TypeError: object of type 'datetime.datetime' has no len()
TypeError
def expand(vevent, href=""): """ Constructs a list of start and end dates for all recurring instances of the event defined in vevent. It considers RRULE as well as RDATE and EXDATE properties. In case of unsupported recursion rules an UnsupportedRecurrence exception is thrown. If the timezone defined in vevent is not understood by icalendar, default_tz is used. :param vevent: vevent to be expanded :type vevent: icalendar.cal.Event :param href: the href of the vevent, used for more informative logging and nothing else :type href: str :returns: list of start and end (date)times of the expanded event :rtyped list(tuple(datetime, datetime)) """ # we do this now and than never care about the "real" end time again if "DURATION" in vevent: duration = vevent["DURATION"].dt else: duration = vevent["DTEND"].dt - vevent["DTSTART"].dt events_tz = getattr(vevent["DTSTART"].dt, "tzinfo", None) allday = not isinstance(vevent["DTSTART"].dt, datetime) def sanitize_datetime(date): if allday and isinstance(date, datetime): date = date.date() if events_tz is not None: date = events_tz.localize(date) return date rrule_param = vevent.get("RRULE") if rrule_param is not None: vevent = sanitize_rrule(vevent) # dst causes problem while expanding the rrule, therefore we transform # everything to naive datetime objects and tranform back after # expanding # See https://github.com/dateutil/dateutil/issues/102 dtstart = vevent["DTSTART"].dt if events_tz: dtstart = dtstart.replace(tzinfo=None) rrule = dateutil.rrule.rrulestr(rrule_param.to_ical().decode(), dtstart=dtstart) if rrule._until is None: # rrule really doesn't like to calculate all recurrences until # eternity, so we only do it until 2037, because a) I'm not sure # if python can deal with larger datetime values yet and b) pytz # doesn't know any larger transition times rrule._until = datetime(2037, 12, 31) elif getattr(rrule._until, "tzinfo", None): rrule._until = rrule._until.astimezone(events_tz).replace(tzinfo=None) rrule = map(sanitize_datetime, rrule) logger.debug( "calculating recurrence dates for {0}, this might take some time.".format( href ) ) # RRULE and RDATE may specify the same date twice, it is recommended by # the RFC to consider this as only one instance dtstartl = set(rrule) if not dtstartl: raise UnsupportedRecurrence() else: dtstartl = {vevent["DTSTART"].dt} def get_dates(vevent, key): dates = vevent.get(key) if dates is None: return if not isinstance(dates, list): dates = [dates] dates = (leaf.dt for tree in dates for leaf in tree.dts) dates = localize_strip_tz(dates, events_tz) return map(sanitize_datetime, dates) # include explicitly specified recursion dates dtstartl.update(get_dates(vevent, "RDATE") or ()) # remove excluded dates for date in get_dates(vevent, "EXDATE") or (): try: dtstartl.remove(date) except KeyError: logger.warn( "In event {}, excluded instance starting at {} not found, " "event might be invalid.".format(href, date) ) dtstartend = [(start, start + duration) for start in dtstartl] # not necessary, but I prefer deterministic output dtstartend.sort() return dtstartend
def expand(vevent, href=""): """ Constructs a list of start and end dates for all recurring instances of the event defined in vevent. It considers RRULE as well as RDATE and EXDATE properties. In case of unsupported recursion rules an UnsupportedRecurrence exception is thrown. If the timezone defined in vevent is not understood by icalendar, default_tz is used. :param vevent: vevent to be expanded :type vevent: icalendar.cal.Event :param href: the href of the vevent, used for more informative logging and nothing else :type href: str :returns: list of start and end (date)times of the expanded event :rtyped list(tuple(datetime, datetime)) """ # we do this now and than never care about the "real" end time again if "DURATION" in vevent: duration = vevent["DURATION"].dt else: duration = vevent["DTEND"].dt - vevent["DTSTART"].dt events_tz = getattr(vevent["DTSTART"].dt, "tzinfo", None) allday = not isinstance(vevent["DTSTART"].dt, datetime) def sanitize_datetime(date): if allday and isinstance(date, datetime): date = date.date() if events_tz is not None: date = events_tz.localize(date) return date rrule_param = vevent.get("RRULE") if rrule_param is not None: vevent = sanitize_rrule(vevent) # dst causes problem while expanding the rrule, therefore we transform # everything to naive datetime objects and tranform back after # expanding # See https://github.com/dateutil/dateutil/issues/102 dtstart = vevent["DTSTART"].dt if events_tz: dtstart = dtstart.replace(tzinfo=None) rrule = dateutil.rrule.rrulestr(rrule_param.to_ical().decode(), dtstart=dtstart) if rrule._until is None: # rrule really doesn't like to calculate all recurrences until # eternity, so we only do it until 2037, because a) I'm not sure # if python can deal with larger datetime values yet and b) pytz # doesn't know any larger transition times rrule._until = datetime(2037, 12, 31) elif getattr(rrule._until, "tzinfo", None): rrule._until = rrule._until.astimezone(events_tz).replace(tzinfo=None) rrule = map(sanitize_datetime, rrule) logger.debug( "calculating recurrence dates for {0}, this might take some time.".format( href ) ) # RRULE and RDATE may specify the same date twice, it is recommended by # the RFC to consider this as only one instance dtstartl = set(rrule) if not dtstartl: raise UnsupportedRecurrence() else: dtstartl = {vevent["DTSTART"].dt} def get_dates(vevent, key): dates = vevent.get(key) if dates is None: return if not isinstance(dates, list): dates = [dates] dates = (leaf.dt for tree in dates for leaf in tree.dts) dates = localize_strip_tz(dates, events_tz) return map(sanitize_datetime, dates) # include explicitly specified recursion dates dtstartl.update(get_dates(vevent, "RDATE") or ()) # remove excluded dates for date in get_dates(vevent, "EXDATE") or (): dtstartl.remove(date) dtstartend = [(start, start + duration) for start in dtstartl] # not necessary, but I prefer deterministic output dtstartend.sort() return dtstartend
https://github.com/pimutils/khal/issues/432
Unknown exception happened. Traceback (most recent call last): File "/usr/lib/python3.5/site-packages/khal/khalendar/khalendar.py", line 286, in _update_vevent update(event.raw, href=href, etag=etag, calendar=calendar) File "/usr/lib/python3.5/site-packages/khal/khalendar/backend.py", line 260, in update self._update_impl(vevent, href, calendar) File "/usr/lib/python3.5/site-packages/khal/khalendar/backend.py", line 349, in _update_impl dtstartend = aux.expand(vevent, href) File "/usr/lib/python3.5/site-packages/khal/khalendar/aux.py", line 106, in expand dtstartl.remove(date) KeyError: datetime.datetime(2011, 9, 24, 15, 50, tzinfo=<DstTzInfo 'America/New_York' EDT-1 day, 20:00:00 DST>) warning: Skipping home/00D6A925-90F7-4663-AE13-E8BD1655EF77.ics: datetime.datetime(2011, 9, 24, 15, 50, tzinfo=<DstTzInfo 'America/New_York' EDT-1 day, 20:00:00 DST>) warning: This event will not be available in khal.
KeyError
def get_event(self, href, calendar): return self._cover_event(self._backend.get(href, calendar=calendar))
def get_event(self, href, calendar): return self._cover_event(self._backend.get(href, calendar))
https://github.com/pimutils/khal/issues/377
Traceback (most recent call last): File "/usr/lib/python3.5/site-packages/khal/ui/__init__.py", line 891, in start_pane loop.run() File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 278, in run self._run() File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 376, in _run self.event_loop.run() File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 682, in run self._loop() File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 719, in _loop self._watch_files[fd]() File "/usr/lib/python3.5/site-packages/urwid/raw_display.py", line 393, in <lambda> event_loop, callback, self.get_available_raw_input()) File "/usr/lib/python3.5/site-packages/urwid/raw_display.py", line 493, in parse_input callback(processed, processed_codes) File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 403, in _update self.process_input(keys) File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 509, in process_input something_handled |= bool(self.unhandled_input(k)) File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 555, in unhandled_input return self._unhandled_input(input) File "/usr/lib/python3.5/site-packages/khal/ui/base.py", line 149, in on_key_press self.backtrack() File "/usr/lib/python3.5/site-packages/khal/ui/base.py", line 139, in backtrack cb(data) File "/usr/lib/python3.5/site-packages/khal/ui/__init__.py", line 775, in cleanup event = self.collection.get_event(href, account) File "/usr/lib/python3.5/site-packages/khal/khalendar/khalendar.py", line 234, in get_event return self._cover_event(self._backend.get(href, calendar)) File "/usr/lib/python3.5/site-packages/khal/khalendar/backend.py", line 544, in get assert calendar is not None AssertionError
AssertionError
def __init__(self, eventcolumn): self.eventcolumn = eventcolumn self.events = None self.list_walker = None pile = urwid.Filler(urwid.Pile([])) urwid.WidgetWrap.__init__(self, pile) self.update_by_date()
def __init__(self, eventcolumn): self.eventcolumn = eventcolumn self.list_walker = None pile = urwid.Filler(urwid.Pile([])) urwid.WidgetWrap.__init__(self, pile) self.update_by_date()
https://github.com/pimutils/khal/issues/352
Traceback (most recent call last): File "/usr/bin/ikhal", line 9, in <module> load_entry_point('khal==0.7.1.dev128+ng619ddd6.d20160219', 'console_scripts', 'ikhal')() File "/usr/lib/python3.5/site-packages/click/core.py", line 716, in __call__ return self.main(*args, **kwargs) File "/usr/lib/python3.5/site-packages/click/core.py", line 696, in main rv = self.invoke(ctx) File "/usr/lib/python3.5/site-packages/click/core.py", line 889, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/lib/python3.5/site-packages/click/core.py", line 534, in invoke return callback(*args, **kwargs) File "/usr/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func return f(get_current_context(), *args, **kwargs) File "/usr/lib/python3.5/site-packages/khal/cli.py", line 361, in interactive_cli controllers.interactive(build_collection(ctx), ctx.obj['conf']) File "/usr/lib/python3.5/site-packages/khal/controllers.py", line 209, in interactive description='do something') File "/usr/lib/python3.5/site-packages/khal/ui/__init__.py", line 715, in __init__ get_styles=collection.get_styles File "/usr/lib/python3.5/site-packages/khal/ui/calendarwidget.py", line 591, in __init__ self.set_focus_date(initial) File "/usr/lib/python3.5/site-packages/khal/ui/calendarwidget.py", line 605, in set_focus_date self.box.set_focus_date(a_day) File "/usr/lib/python3.5/site-packages/khal/ui/calendarwidget.py", line 295, in set_focus_date self.body.set_focus_date(a_day) File "/usr/lib/python3.5/site-packages/khal/ui/calendarwidget.py", line 370, in set_focus_date self[self.focus]._set_focus_position(column) File "/usr/lib/python3.5/site-packages/khal/ui/calendarwidget.py", line 139, in _set_focus_position self.on_date_change(self.contents[position][0].date) File "/usr/lib/python3.5/site-packages/khal/ui/__init__.py", line 764, in show_date self.eventscolumn.original_widget.current_date = date File "/usr/lib/python3.5/site-packages/khal/ui/__init__.py", line 312, in current_date if len(self.events.events) > 0: AttributeError: 'EventList' object has no attribute 'events'
AttributeError
def update_by_date(self, this_date=date.today()): if this_date is None: # this_date might be None return date_text = urwid.Text( this_date.strftime(self.eventcolumn.pane.conf["locale"]["longdateformat"]) ) self.events = sorted(self.eventcolumn.pane.collection.get_events_on(this_date)) event_list = [ urwid.AttrMap( U_Event(event, this_date=this_date, eventcolumn=self.eventcolumn), "calendar " + event.calendar, "reveal focus", ) for event in self.events ] event_count = len(event_list) if not event_list: event_list = [urwid.Text("no scheduled events")] self.list_walker = urwid.SimpleFocusListWalker(event_list) self._w = urwid.Frame(urwid.ListBox(self.list_walker), header=date_text) return event_count
def update_by_date(self, this_date=date.today()): if this_date is None: # this_date might be None return date_text = urwid.Text( this_date.strftime(self.eventcolumn.pane.conf["locale"]["longdateformat"]) ) events = sorted(self.eventcolumn.pane.collection.get_events_on(this_date)) event_list = [ urwid.AttrMap( U_Event(event, this_date=this_date, eventcolumn=self.eventcolumn), "calendar " + event.calendar, "reveal focus", ) for event in events ] event_count = len(event_list) if not event_list: event_list = [urwid.Text("no scheduled events")] self.list_walker = urwid.SimpleFocusListWalker(event_list) self._w = urwid.Frame(urwid.ListBox(self.list_walker), header=date_text) return event_count
https://github.com/pimutils/khal/issues/352
Traceback (most recent call last): File "/usr/bin/ikhal", line 9, in <module> load_entry_point('khal==0.7.1.dev128+ng619ddd6.d20160219', 'console_scripts', 'ikhal')() File "/usr/lib/python3.5/site-packages/click/core.py", line 716, in __call__ return self.main(*args, **kwargs) File "/usr/lib/python3.5/site-packages/click/core.py", line 696, in main rv = self.invoke(ctx) File "/usr/lib/python3.5/site-packages/click/core.py", line 889, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/lib/python3.5/site-packages/click/core.py", line 534, in invoke return callback(*args, **kwargs) File "/usr/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func return f(get_current_context(), *args, **kwargs) File "/usr/lib/python3.5/site-packages/khal/cli.py", line 361, in interactive_cli controllers.interactive(build_collection(ctx), ctx.obj['conf']) File "/usr/lib/python3.5/site-packages/khal/controllers.py", line 209, in interactive description='do something') File "/usr/lib/python3.5/site-packages/khal/ui/__init__.py", line 715, in __init__ get_styles=collection.get_styles File "/usr/lib/python3.5/site-packages/khal/ui/calendarwidget.py", line 591, in __init__ self.set_focus_date(initial) File "/usr/lib/python3.5/site-packages/khal/ui/calendarwidget.py", line 605, in set_focus_date self.box.set_focus_date(a_day) File "/usr/lib/python3.5/site-packages/khal/ui/calendarwidget.py", line 295, in set_focus_date self.body.set_focus_date(a_day) File "/usr/lib/python3.5/site-packages/khal/ui/calendarwidget.py", line 370, in set_focus_date self[self.focus]._set_focus_position(column) File "/usr/lib/python3.5/site-packages/khal/ui/calendarwidget.py", line 139, in _set_focus_position self.on_date_change(self.contents[position][0].date) File "/usr/lib/python3.5/site-packages/khal/ui/__init__.py", line 764, in show_date self.eventscolumn.original_widget.current_date = date File "/usr/lib/python3.5/site-packages/khal/ui/__init__.py", line 312, in current_date if len(self.events.events) > 0: AttributeError: 'EventList' object has no attribute 'events'
AttributeError
def fromVEvents(cls, events_list, ref=None, **kwargs): """ :type events: list """ assert isinstance(events_list, list) vevents = dict() if len(events_list) == 1: vevents["PROTO"] = events_list[0] # TODO set mutable = False else: for event in events_list: if "RECURRENCE-ID" in event: if invalid_timezone(event["RECURRENCE-ID"]): default_timezone = kwargs["locale"]["default_timezone"] recur_id = default_timezone.localize(event["RECURRENCE-ID"].dt) ident = str(to_unix_time(recur_id)) else: ident = str(to_unix_time(event["RECURRENCE-ID"].dt)) vevents[ident] = event else: vevents["PROTO"] = event if ref is None: ref = "PROTO" try: if type(vevents[ref]["DTSTART"].dt) != type(vevents[ref]["DTEND"].dt): # flake8: noqa raise ValueError( "DTSTART and DTEND should be of the same type (datetime or date)" ) except KeyError: pass if kwargs.get("start"): instcls = cls._get_type_from_date(kwargs.get("start")) else: instcls = cls._get_type_from_vDDD(vevents[ref]["DTSTART"]) return instcls(vevents, ref=ref, **kwargs)
def fromVEvents(cls, events_list, ref=None, **kwargs): """ :type events: list """ assert isinstance(events_list, list) vevents = dict() if len(events_list) == 1: vevents["PROTO"] = events_list[0] # TODO set mutable = False else: for event in events_list: if "RECURRENCE-ID" in event: if invalid_timezone(event["RECURRENCE-ID"]): default_timezone = kwargs["locale"]["default_timezone"] recur_id = default_timezone.localize(event["RECURRENCE-ID"].dt) ident = str(to_unix_time(recur_id)) else: ident = str(to_unix_time(event["RECURRENCE-ID"].dt)) vevents[ident] = event else: vevents["PROTO"] = event if ref is None: ref = "PROTO" try: if type(vevents[ref]["DTSTART"].dt) != type(vevents[ref]["DTEND"].dt): # flake8: noqa raise ValueError( "DTSTART and DTEND should be of the same type (datetime or date)" ) except KeyError: pass instcls = cls._get_type_from_vDDD(vevents[ref]["DTSTART"]) return instcls(vevents, ref=ref, **kwargs)
https://github.com/pimutils/khal/issues/312
Traceback (most recent call last): File "/usr/local/bin/khal", line 9, in <module> load_entry_point('khal==0.7.0', 'console_scripts', 'khal')() File "/usr/local/lib/python2.7/site-packages/click/core.py", line 716, in __call__ return self.main(*args, **kwargs) File "/usr/local/lib/python2.7/site-packages/click/core.py", line 696, in main rv = self.invoke(ctx) File "/usr/local/lib/python2.7/site-packages/click/core.py", line 1037, in invoke return Command.invoke(self, ctx) File "/usr/local/lib/python2.7/site-packages/click/core.py", line 889, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke return callback(*args, **kwargs) File "/usr/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func return f(get_current_context(), *args, **kwargs) File "/usr/local/lib/python2.7/site-packages/khal/cli.py", line 226, in cli ctx.invoke(cli.commands[command]) File "/usr/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke return callback(*args, **kwargs) File "/usr/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func return f(get_current_context(), *args, **kwargs) File "/usr/local/lib/python2.7/site-packages/khal/cli.py", line 254, in calendar full=full File "/usr/local/lib/python2.7/site-packages/khal/controllers.py", line 149, in calendar show_all_days=show_all_days, full=full, **kwargs) File "/usr/local/lib/python2.7/site-packages/khal/controllers.py", line 122, in get_agenda items = event.relative_to(day, full).splitlines() File "/usr/local/lib/python2.7/site-packages/khal/khalendar/event.py", line 374, in relative_to if self.start_local < day_start: File "/usr/local/lib/python2.7/site-packages/khal/khalendar/event.py", line 486, in start_local return self.start.astimezone(self._locale['local_timezone']) File "/usr/local/lib/python2.7/site-packages/khal/khalendar/event.py", line 473, in start return self._locale['default_timezone'].localize(self._start) File "/usr/lib/python2.7/site-packages/pytz/tzinfo.py", line 303, in localize if dt.tzinfo is not None: AttributeError: 'datetime.date' object has no attribute 'tzinfo'
AttributeError
def toggle_delete(self): # TODO unify, either directly delete *normal* events as well # or stage recurring deletion as well def delete_this(_): self.event.delete_instance(self.event.recurrence_id) self.eventcolumn.pane.collection.update(self.event) self.eventcolumn.pane.window.backtrack() def delete_future(_): self.eventcolumn.pane.window.backtrack() def delete_all(_): if self.uid in self.eventcolumn.pane.deleted: self.eventcolumn.pane.deleted.remove(self.uid) else: self.eventcolumn.pane.deleted.append(self.uid) self.eventcolumn.pane.window.backtrack() if self.event.readonly: self.eventcolumn.pane.window.alert( ("light red", "Calendar {} is read-only.".format(self.event.calendar)) ) return if self.uid in self.eventcolumn.pane.deleted: self.eventcolumn.pane.deleted.remove(self.uid) else: if self.event.recurring: overlay = urwid.Overlay( DeleteDialog( delete_this, delete_future, delete_all, self.eventcolumn.pane.window.backtrack, ), self.eventcolumn.pane, "center", ("relative", 70), ("relative", 70), None, ) self.eventcolumn.pane.window.open(overlay) else: self.eventcolumn.pane.deleted.append(self.uid) self.set_title()
def toggle_delete(self): # TODO unify, either directly delete *normal* events as well # or stage recurring deletion as well def delete_this(_): if self.event.ref == "PROTO": instance = self.event.start else: instance = self.event.ref self.event.delete_instance(instance) self.eventcolumn.pane.collection.update(self.event) self.eventcolumn.pane.window.backtrack() def delete_future(_): self.eventcolumn.pane.window.backtrack() def delete_all(_): if self.uid in self.eventcolumn.pane.deleted: self.eventcolumn.pane.deleted.remove(self.uid) else: self.eventcolumn.pane.deleted.append(self.uid) self.eventcolumn.pane.window.backtrack() if self.event.readonly: self.eventcolumn.pane.window.alert( ("light red", "Calendar {} is read-only.".format(self.event.calendar)) ) return if self.uid in self.eventcolumn.pane.deleted: self.eventcolumn.pane.deleted.remove(self.uid) else: if self.event.recurring: overlay = urwid.Overlay( DeleteDialog( delete_this, delete_future, delete_all, self.eventcolumn.pane.window.backtrack, ), self.eventcolumn.pane, "center", ("relative", 70), ("relative", 70), None, ) self.eventcolumn.pane.window.open(overlay) else: self.eventcolumn.pane.deleted.append(self.uid) self.set_title()
https://github.com/pimutils/khal/issues/299
debug: using the config file at /home/eisfreak7/.config/khal/khal.conf debug: khal 0.6.1.dev205+ngc8a11b0.d20151117 debug: Using config: debug: [calendars] debug: [[cal1]] debug: path: /home/timo/data/calendars/cal1.ics/ debug: color: dark blue debug: readonly: False debug: type: calendar debug: [[cal2]] debug: path: /home/timo/data/calendars/cal2.ics/ debug: color: light blue debug: readonly: False debug: type: calendar debug: [[cal3]] debug: path: /home/timo/data/calendars/cal3.ics/ debug: color: dark magenta debug: readonly: False debug: type: calendar debug: [[cal4]] debug: path: /home/timo/data/calendars/cal4.ics/ debug: color: dark cyan debug: readonly: False debug: type: calendar debug: [locale] debug: longdateformat: %Y-%m-%d debug: longdatetimeformat: %Y-%m-%d %H:%M debug: datetimeformat: %y-%m-%d %H:%M debug: timeformat: %H:%M debug: dateformat: %y-%m-%d debug: encoding: utf-8 debug: firstweekday: 0 debug: unicode_symbols: True debug: default_timezone: Europe/Berlin debug: local_timezone: Europe/Berlin debug: weeknumbers: False debug: [default] debug: default_command: agenda debug: print_new: event debug: days: 2 debug: default_calendar: None debug: show_all_days: False debug: highlight_event_days: False debug: [sqlite] debug: path: /home/eisfreak7/.local/share/khal/khal.db debug: [keybindings] debug: up: ['up', 'k'] debug: down: ['down', 'j'] debug: right: ['right', 'l', ' '] debug: left: ['left', 'h', 'backspace'] debug: new: ['n'] debug: delete: ['d'] debug: view: ['enter', 'tab'] debug: today: ['t'] debug: save: ['meta enter'] debug: duplicate: ['p'] debug: [view] debug: event_view_weighting: 1 debug: event_view_always_visible: False debug: theme: dark debug: frame: False debug: [highlight_days] debug: method: fg debug: color: debug: multiple: debug: default_color: debug: created version table debug: tables for calendar cal1 exist debug: created version table debug: tables for calendar cal2 exist debug: created version table debug: tables for calendar cal3 exist debug: created version table debug: tables for calendar cal4 exist Traceback (most recent call last): File "/usr/lib/python3.5/site-packages/khal/ui/__init__.py", line 675, in start_pane loop.run() File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 278, in run self._run() File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 375, in _run self.event_loop.run() File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 678, in run self._loop() File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 715, in _loop self._watch_files[fd]() File "/usr/lib/python3.5/site-packages/urwid/raw_display.py", line 392, in <lambda> event_loop, callback, self.get_available_raw_input()) File "/usr/lib/python3.5/site-packages/urwid/raw_display.py", line 492, in parse_input callback(processed, processed_codes) File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 399, in _update self.process_input(keys) File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 499, in process_input k = self._topmost_widget.keypress(self.screen_size, k) File "/usr/lib/python3.5/site-packages/urwid/wimp.py", line 643, in keypress return self._current_widget.keypress(size, key) File "/usr/lib/python3.5/site-packages/urwid/container.py", line 1128, in keypress return self.body.keypress( (maxcol, remaining), key ) File "/usr/lib/python3.5/site-packages/urwid/container.py", line 592, in keypress *self.calculate_padding_filler(size, True)), key) File "/usr/lib/python3.5/site-packages/urwid/container.py", line 1587, in keypress key = self.focus.keypress(tsize, key) File "/usr/lib/python3.5/site-packages/urwid/container.py", line 2269, in keypress key = w.keypress((mc,) + size[1:], key) File "/usr/lib/python3.5/site-packages/urwid/container.py", line 1587, in keypress key = self.focus.keypress(tsize, key) File "/usr/lib/python3.5/site-packages/urwid/container.py", line 2269, in keypress key = w.keypress((mc,) + size[1:], key) File "/usr/lib/python3.5/site-packages/urwid/wimp.py", line 535, in keypress self._emit('click') File "/usr/lib/python3.5/site-packages/urwid/widget.py", line 463, in _emit signals.emit_signal(self, name, self, *args) File "/usr/lib/python3.5/site-packages/urwid/signals.py", line 264, in emit result |= self._call_callback(callback, user_arg, user_args, args) File "/usr/lib/python3.5/site-packages/urwid/signals.py", line 294, in _call_callback return bool(callback(*args_to_pass)) File "/usr/lib/python3.5/site-packages/khal/ui/__init__.py", line 91, in delete_this self.event.delete_instance(instance) File "/usr/lib/python3.5/site-packages/khal/khalendar/event.py", line 422, in delete_instance delete_instance(self._vevents['PROTO'], instance) File "/usr/lib/python3.5/site-packages/khal/khalendar/aux.py", line 279, in delete_instance _add_exdate(vevent, instance) File "/usr/lib/python3.5/site-packages/khal/khalendar/aux.py", line 237, in _add_exdate vevent.add('EXDATE', instance) File "/usr/lib/python3.5/site-packages/icalendar/cal.py", line 174, in add value = self._encode(name, value, parameters, encode) File "/usr/lib/python3.5/site-packages/icalendar/cal.py", line 126, in _encode obj = klass(value) File "/usr/lib/python3.5/site-packages/icalendar/prop.py", line 247, in __init__ dt = vDDDTypes(dt) File "/usr/lib/python3.5/site-packages/icalendar/prop.py", line 277, in __init__ raise ValueError('You must use datetime, date, timedelta or time') ValueError: You must use datetime, date, timedelta or time
ValueError
def delete_this(_): self.event.delete_instance(self.event.recurrence_id) self.eventcolumn.pane.collection.update(self.event) self.eventcolumn.pane.window.backtrack()
def delete_this(_): if self.event.ref == "PROTO": instance = self.event.start else: instance = self.event.ref self.event.delete_instance(instance) self.eventcolumn.pane.collection.update(self.event) self.eventcolumn.pane.window.backtrack()
https://github.com/pimutils/khal/issues/299
debug: using the config file at /home/eisfreak7/.config/khal/khal.conf debug: khal 0.6.1.dev205+ngc8a11b0.d20151117 debug: Using config: debug: [calendars] debug: [[cal1]] debug: path: /home/timo/data/calendars/cal1.ics/ debug: color: dark blue debug: readonly: False debug: type: calendar debug: [[cal2]] debug: path: /home/timo/data/calendars/cal2.ics/ debug: color: light blue debug: readonly: False debug: type: calendar debug: [[cal3]] debug: path: /home/timo/data/calendars/cal3.ics/ debug: color: dark magenta debug: readonly: False debug: type: calendar debug: [[cal4]] debug: path: /home/timo/data/calendars/cal4.ics/ debug: color: dark cyan debug: readonly: False debug: type: calendar debug: [locale] debug: longdateformat: %Y-%m-%d debug: longdatetimeformat: %Y-%m-%d %H:%M debug: datetimeformat: %y-%m-%d %H:%M debug: timeformat: %H:%M debug: dateformat: %y-%m-%d debug: encoding: utf-8 debug: firstweekday: 0 debug: unicode_symbols: True debug: default_timezone: Europe/Berlin debug: local_timezone: Europe/Berlin debug: weeknumbers: False debug: [default] debug: default_command: agenda debug: print_new: event debug: days: 2 debug: default_calendar: None debug: show_all_days: False debug: highlight_event_days: False debug: [sqlite] debug: path: /home/eisfreak7/.local/share/khal/khal.db debug: [keybindings] debug: up: ['up', 'k'] debug: down: ['down', 'j'] debug: right: ['right', 'l', ' '] debug: left: ['left', 'h', 'backspace'] debug: new: ['n'] debug: delete: ['d'] debug: view: ['enter', 'tab'] debug: today: ['t'] debug: save: ['meta enter'] debug: duplicate: ['p'] debug: [view] debug: event_view_weighting: 1 debug: event_view_always_visible: False debug: theme: dark debug: frame: False debug: [highlight_days] debug: method: fg debug: color: debug: multiple: debug: default_color: debug: created version table debug: tables for calendar cal1 exist debug: created version table debug: tables for calendar cal2 exist debug: created version table debug: tables for calendar cal3 exist debug: created version table debug: tables for calendar cal4 exist Traceback (most recent call last): File "/usr/lib/python3.5/site-packages/khal/ui/__init__.py", line 675, in start_pane loop.run() File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 278, in run self._run() File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 375, in _run self.event_loop.run() File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 678, in run self._loop() File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 715, in _loop self._watch_files[fd]() File "/usr/lib/python3.5/site-packages/urwid/raw_display.py", line 392, in <lambda> event_loop, callback, self.get_available_raw_input()) File "/usr/lib/python3.5/site-packages/urwid/raw_display.py", line 492, in parse_input callback(processed, processed_codes) File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 399, in _update self.process_input(keys) File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 499, in process_input k = self._topmost_widget.keypress(self.screen_size, k) File "/usr/lib/python3.5/site-packages/urwid/wimp.py", line 643, in keypress return self._current_widget.keypress(size, key) File "/usr/lib/python3.5/site-packages/urwid/container.py", line 1128, in keypress return self.body.keypress( (maxcol, remaining), key ) File "/usr/lib/python3.5/site-packages/urwid/container.py", line 592, in keypress *self.calculate_padding_filler(size, True)), key) File "/usr/lib/python3.5/site-packages/urwid/container.py", line 1587, in keypress key = self.focus.keypress(tsize, key) File "/usr/lib/python3.5/site-packages/urwid/container.py", line 2269, in keypress key = w.keypress((mc,) + size[1:], key) File "/usr/lib/python3.5/site-packages/urwid/container.py", line 1587, in keypress key = self.focus.keypress(tsize, key) File "/usr/lib/python3.5/site-packages/urwid/container.py", line 2269, in keypress key = w.keypress((mc,) + size[1:], key) File "/usr/lib/python3.5/site-packages/urwid/wimp.py", line 535, in keypress self._emit('click') File "/usr/lib/python3.5/site-packages/urwid/widget.py", line 463, in _emit signals.emit_signal(self, name, self, *args) File "/usr/lib/python3.5/site-packages/urwid/signals.py", line 264, in emit result |= self._call_callback(callback, user_arg, user_args, args) File "/usr/lib/python3.5/site-packages/urwid/signals.py", line 294, in _call_callback return bool(callback(*args_to_pass)) File "/usr/lib/python3.5/site-packages/khal/ui/__init__.py", line 91, in delete_this self.event.delete_instance(instance) File "/usr/lib/python3.5/site-packages/khal/khalendar/event.py", line 422, in delete_instance delete_instance(self._vevents['PROTO'], instance) File "/usr/lib/python3.5/site-packages/khal/khalendar/aux.py", line 279, in delete_instance _add_exdate(vevent, instance) File "/usr/lib/python3.5/site-packages/khal/khalendar/aux.py", line 237, in _add_exdate vevent.add('EXDATE', instance) File "/usr/lib/python3.5/site-packages/icalendar/cal.py", line 174, in add value = self._encode(name, value, parameters, encode) File "/usr/lib/python3.5/site-packages/icalendar/cal.py", line 126, in _encode obj = klass(value) File "/usr/lib/python3.5/site-packages/icalendar/prop.py", line 247, in __init__ dt = vDDDTypes(dt) File "/usr/lib/python3.5/site-packages/icalendar/prop.py", line 277, in __init__ raise ValueError('You must use datetime, date, timedelta or time') ValueError: You must use datetime, date, timedelta or time
ValueError
def vertical_month( month=datetime.date.today().month, year=datetime.date.today().year, today=datetime.date.today(), weeknumber=False, count=3, firstweekday=0, ): """ returns a list() of str() of weeks for a vertical arranged calendar :param month: first month of the calendar, if non given, current month is assumed :type month: int :param year: year of the first month included, if non given, current year is assumed :type year: int :param today: day highlighted, if non is given, current date is assumed :type today: datetime.date() :param weeknumber: if not False the iso weeknumber will be shown for each week, if weeknumber is 'right' it will be shown in its own column, if it is 'left' it will be shown interleaved with the month names :type weeknumber: str/bool :returns: calendar strings, may also include some ANSI (color) escape strings :rtype: list() of str() """ khal = list() w_number = " " if weeknumber == "right" else "" calendar.setfirstweekday(firstweekday) _calendar = calendar.Calendar(firstweekday) khal.append(bstring(" " + calendar.weekheader(2) + " " + w_number)) for _ in range(count): for week in _calendar.monthdatescalendar(year, month): new_month = len([day for day in week if day.day == 1]) strweek = str_week(week, today) if new_month: m_name = bstring(month_abbr(week[6].month).ljust(4)) elif weeknumber == "left": m_name = bstring(" {:2} ".format(getweeknumber(week[0]))) else: m_name = " " if weeknumber == "right": w_number = bstring(" {}".format(getweeknumber(week[0]))) else: w_number = "" sweek = m_name + strweek + w_number if sweek != khal[-1]: khal.append(sweek) month = month + 1 if month > 12: month = 1 year = year + 1 return khal
def vertical_month( month=datetime.date.today().month, year=datetime.date.today().year, today=datetime.date.today(), weeknumber=False, count=3, firstweekday=0, ): """ returns a list() of str() of weeks for a vertical arranged calendar :param month: first month of the calendar, if non given, current month is assumed :type month: int :param year: year of the first month included, if non given, current year is assumed :type year: int :param today: day highlighted, if non is given, current date is assumed :type today: datetime.date() :param weeknumber: if not False the iso weeknumber will be shown for each week, if weeknumber is 'right' it will be shown in its own column, if it is 'left' it will be shown interleaved with the month names :type weeknumber: str/bool :returns: calendar strings, may also include some ANSI (color) escape strings :rtype: list() of str() """ khal = list() w_number = " " if weeknumber == "right" else "" calendar.setfirstweekday(firstweekday) _calendar = calendar.Calendar(firstweekday) khal.append(bstring(" " + calendar.weekheader(2) + " " + w_number)) for _ in range(count): for week in _calendar.monthdatescalendar(year, month): new_month = len([day for day in week if day.day == 1]) strweek = str_week(week, today) if new_month: m_name = bstring(calendar.month_abbr[week[6].month].ljust(4)) elif weeknumber == "left": m_name = bstring(" {:2} ".format(getweeknumber(week[0]))) else: m_name = " " if weeknumber == "right": w_number = bstring(" {}".format(getweeknumber(week[0]))) else: w_number = "" sweek = m_name + strweek + w_number if sweek != khal[-1]: khal.append(sweek) month = month + 1 if month > 12: month = 1 year = year + 1 return khal
https://github.com/pimutils/khal/issues/142
debug: using the config file at /home/foo/.config/khal/khal.conf debug: Using config: debug: [calendars] debug: [[home]] debug: path = /home/foo/.khal/calendars/home/ debug: color = dark blue debug: [[work]] debug: path = /home/foo/.khal/calendars/home/ debug: color = yellow debug: debug: [sqlite] debug: path = /home/foo/.khal/khal.db debug: debug: [locale] debug: timeformat = %H:%M debug: dateformat = %d.%m. debug: longdateformat = %d.%m.%Y debug: datetimeformat = %d.%m. %H:%M debug: longdatetimeformat = %d.%m.%Y %H:%M debug: debug: firstweekday = 0 debug: weeknumbers = False debug: local_timezone = Europe/Berlin debug: default_timezone = America/New_York debug: encoding = utf-8 debug: unicode_symbols = True debug: debug: [default] debug: default_command = calendar debug: default_calendar = home debug: show_all_days = False debug: created version table debug: created accounts table debug: tables for calendar home exist debug: created version table debug: created accounts table debug: tables for calendar work exist Traceback (most recent call last): File "/usr/bin/khal", line 9, in <module> load_entry_point('khal==0.4.0.dev-124-g46ae09e-dirty', 'console_scripts', 'khal')() File "/usr/lib/python2.7/site-packages/click/core.py", line 610, in __call__ return self.main(*args, **kwargs) File "/usr/lib/python2.7/site-packages/click/core.py", line 590, in main rv = self.invoke(ctx) File "/usr/lib/python2.7/site-packages/click/core.py", line 916, in invoke return Command.invoke(self, ctx) File "/usr/lib/python2.7/site-packages/click/core.py", line 782, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/lib/python2.7/site-packages/click/core.py", line 416, in invoke return callback(*args, **kwargs) File "/usr/lib/python2.7/site-packages/khal/cli.py", line 161, in cli ctx.invoke(cli.commands[command]) File "/usr/lib/python2.7/site-packages/click/core.py", line 416, in invoke return callback(*args, **kwargs) File "/usr/lib/python2.7/site-packages/khal/cli.py", line 182, in calendar events=events File "/usr/lib/python2.7/site-packages/khal/controllers.py", line 138, in __init__ echo('\n'.join(rows).encode(encoding)) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 452: ordinal not in range(128)
UnicodeDecodeError
def global_options(f): def config_callback(ctx, option, config): prepare_context(ctx, config) def verbosity_callback(ctx, option, verbose): if verbose: logger.setLevel(logging.DEBUG) else: logger.setLevel(logging.INFO) config = click.option( "--config", "-c", default=None, metavar="PATH", help="The config file to use.", is_eager=True, expose_value=False, callback=config_callback, ) verbose = click.option( "--verbose", "-v", is_flag=True, help="Output debugging information.", expose_value=False, callback=verbosity_callback, ) version = click.version_option(version=__version__) return config(verbose(version(f)))
def global_options(f): config = click.option( "--config", "-c", default=None, metavar="PATH", help="The config file to use." ) verbose = click.option( "--verbose", "-v", is_flag=True, help="Output debugging information." ) version = click.version_option(version=__version__) return config(verbose(version(f)))
https://github.com/pimutils/khal/issues/261
(vdir)gour@atmarama ~/p/vdir> ikhal -a gour Traceback (most recent call last): File "/home/gour/prj/vdir/bin/ikhal", line 9, in <module> load_entry_point('khal==0.6.1.dev83+nge9717c8', 'console_scripts', 'ikhal')() File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 700, in __call__ return self.main(*args, **kwargs) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 679, in main with self.make_context(prog_name, args, **extra) as ctx: File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 594, in make_context self.parse_args(ctx, args) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 858, in parse_args value, args = param.handle_parse_result(ctx, opts, args) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 1362, in handle_parse_result self.callback, ctx, self, value) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 56, in invoke_param_callback return callback(ctx, param, value) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/khal/cli.py", line 58, in _multi_calendar_select_callback if 'calendar_selection' in ctx.obj: TypeError: argument of type 'NoneType' is not iterable
TypeError
def prepare_context(ctx, config): assert ctx.obj is None ctx.obj = {} try: ctx.obj["conf"] = conf = get_config(config) except InvalidSettingsError: sys.exit(1) logger.debug("khal %s" % __version__) logger.debug("Using config:") logger.debug(to_unicode(stringify_conf(conf), "utf-8")) if conf is None: raise click.UsageError("Invalid config file, exiting.")
def prepare_context(ctx, config, verbose): if ctx.obj is not None: return if verbose: logger.setLevel(logging.DEBUG) else: logger.setLevel(logging.INFO) ctx.obj = {} try: ctx.obj["conf"] = conf = get_config(config) except InvalidSettingsError: sys.exit(1) logger.debug("khal %s" % __version__) logger.debug("Using config:") logger.debug(to_unicode(stringify_conf(conf), "utf-8")) if conf is None: raise click.UsageError("Invalid config file, exiting.")
https://github.com/pimutils/khal/issues/261
(vdir)gour@atmarama ~/p/vdir> ikhal -a gour Traceback (most recent call last): File "/home/gour/prj/vdir/bin/ikhal", line 9, in <module> load_entry_point('khal==0.6.1.dev83+nge9717c8', 'console_scripts', 'ikhal')() File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 700, in __call__ return self.main(*args, **kwargs) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 679, in main with self.make_context(prog_name, args, **extra) as ctx: File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 594, in make_context self.parse_args(ctx, args) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 858, in parse_args value, args = param.handle_parse_result(ctx, opts, args) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 1362, in handle_parse_result self.callback, ctx, self, value) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 56, in invoke_param_callback return callback(ctx, param, value) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/khal/cli.py", line 58, in _multi_calendar_select_callback if 'calendar_selection' in ctx.obj: TypeError: argument of type 'NoneType' is not iterable
TypeError
def _get_cli(): @click.group(invoke_without_command=True) @global_options @click.pass_context def cli(ctx): # setting the process title so it looks nicer in ps # shows up as 'khal' under linux and as 'python: khal (python2.7)' # under FreeBSD, which is still nicer than the default setproctitle("khal") if not ctx.invoked_subcommand: command = ctx.obj["conf"]["default"]["default_command"] if command: ctx.invoke(cli.commands[command]) else: click.echo(ctx.get_help()) ctx.exit(1) @cli.command() @time_args @multi_calendar_option @click.pass_context def calendar(ctx, days, events, dates): """Print calendar with agenda.""" controllers.calendar( build_collection(ctx), date=dates, firstweekday=ctx.obj["conf"]["locale"]["firstweekday"], encoding=ctx.obj["conf"]["locale"]["encoding"], locale=ctx.obj["conf"]["locale"], weeknumber=ctx.obj["conf"]["locale"]["weeknumbers"], show_all_days=ctx.obj["conf"]["default"]["show_all_days"], days=days or ctx.obj["conf"]["default"]["days"], events=events, ) @cli.command() @time_args @multi_calendar_option @click.pass_context def agenda(ctx, days, events, dates): """Print agenda.""" controllers.agenda( build_collection(ctx), date=dates, firstweekday=ctx.obj["conf"]["locale"]["firstweekday"], encoding=ctx.obj["conf"]["locale"]["encoding"], show_all_days=ctx.obj["conf"]["default"]["show_all_days"], locale=ctx.obj["conf"]["locale"], days=days or ctx.obj["conf"]["default"]["days"], events=events, ) @cli.command() @calendar_option @click.option("--location", "-l", help=("The location of the new event.")) @click.option( "--repeat", "-r", help=("Repeat event: daily, weekly, monthly or yearly.") ) @click.option("--until", "-u", help=("Stop an event repeating on this date.")) @click.argument("description", nargs=-1, required=True) @click.pass_context def new(ctx, calendar, description, location, repeat, until): """Create a new event.""" controllers.new_from_string( build_collection(ctx), calendar, ctx.obj["conf"], list(description), location=location, repeat=repeat, until=until.split(" ") if until is not None else None, ) @cli.command("import") @click.option( "--include-calendar", "-a", help=("The calendar to use."), expose_value=False, callback=_calendar_select_callback, metavar="CAL", ) @click.option("--batch", help=("do not ask for any confirmation."), is_flag=True) @click.option("--random_uid", "-r", help=("Select a random uid."), is_flag=True) @click.argument("ics", type=click.File("rb")) @click.pass_context def import_ics(ctx, ics, batch, random_uid): """Import events from an .ics file. If an event with the same UID is already present in the (implicitly) selected calendar import will ask before updating (i.e. overwriting) that old event with the imported one, unless --batch is given, than it will always update. If this behaviour is not desired, use the `--random-uid` flag to generate a new, random UID. If no calendar is specified (and not `--batch`), you will be asked to choose a calendar. You can either enter the number printed behind each calendar's name or any unique prefix of a calendar's name. """ ics_str = ics.read() controllers.import_ics( build_collection(ctx), ctx.obj["conf"], ics=ics_str, batch=batch, random_uid=random_uid, ) @cli.command() @multi_calendar_option @click.pass_context def interactive(ctx): """Interactive UI. Also launchable via `ikhal`.""" controllers.interactive(build_collection(ctx), ctx.obj["conf"]) @click.command() @global_options @multi_calendar_option @click.pass_context def interactive_cli(ctx): """Interactive UI. Also launchable via `khal interactive`.""" controllers.interactive(build_collection(ctx), ctx.obj["conf"]) @cli.command() @multi_calendar_option @click.pass_context def printcalendars(ctx): """List all calendars.""" click.echo("\n".join(build_collection(ctx).names)) @cli.command() @click.pass_context def printformats(ctx): """Print a date in all formats. Print the date 2013-12-21 10:09 in all configured date(time) formats to check if these locale settings are configured to ones liking.""" from datetime import datetime time = datetime(2013, 12, 21, 10, 9) for strftime_format in [ "longdatetimeformat", "datetimeformat", "longdateformat", "dateformat", "timeformat", ]: dt_str = time.strftime(ctx.obj["conf"]["locale"][strftime_format]) click.echo("{}: {}".format(strftime_format, dt_str)) @cli.command() @multi_calendar_option @click.argument("search_string") @click.pass_context def search(ctx, search_string): """Search for events matching SEARCH_STRING. For repetitive events only one event is currently shown. """ # TODO support for time ranges, location, description etc collection = build_collection(ctx) events = collection.search(search_string) event_column = list() term_width, _ = get_terminal_size() for event in events: desc = textwrap.wrap(event.event_description, term_width) event_column.extend([colored(d, event.color) for d in desc]) click.echo( to_unicode("\n".join(event_column), ctx.obj["conf"]["locale"]["encoding"]) ) @cli.command() @multi_calendar_option @click.argument("datetime", required=False, nargs=-1) @click.pass_context def at(ctx, datetime=None): """Show all events scheduled for DATETIME. if DATETIME is given (or the string `now`) all events scheduled for this moment are shown, if only a time is given, the date is assumed to be today """ collection = build_collection(ctx) locale = ctx.obj["conf"]["locale"] dtime_list = list(datetime) if dtime_list == [] or dtime_list == ["now"]: import datetime dtime = datetime.datetime.now() else: try: dtime, _ = aux.guessdatetimefstr(dtime_list, locale) except ValueError: logger.fatal( "{} is not a valid datetime (matches neither {} nor {} nor" " {})".format( " ".join(dtime_list), locale["timeformat"], locale["datetimeformat"], locale["longdatetimeformat"], ) ) sys.exit(1) dtime = locale["local_timezone"].localize(dtime) dtime = dtime.astimezone(pytz.UTC) events = collection.get_events_at(dtime) event_column = list() term_width, _ = get_terminal_size() for event in events: desc = textwrap.wrap(event.event_description, term_width) event_column.extend([colored(d, event.color) for d in desc]) click.echo( to_unicode("\n".join(event_column), ctx.obj["conf"]["locale"]["encoding"]) ) return cli, interactive_cli
def _get_cli(): @click.group(invoke_without_command=True) @global_options @click.pass_context def cli(ctx, config, verbose): # setting the process title so it looks nicer in ps # shows up as 'khal' under linux and as 'python: khal (python2.7)' # under FreeBSD, which is still nicer than the default setproctitle("khal") prepare_context(ctx, config, verbose) if not ctx.invoked_subcommand: command = ctx.obj["conf"]["default"]["default_command"] if command: ctx.invoke(cli.commands[command]) else: click.echo(ctx.get_help()) ctx.exit(1) @cli.command() @time_args @multi_calendar_option @click.pass_context def calendar(ctx, days, events, dates): """Print calendar with agenda.""" controllers.calendar( build_collection(ctx), date=dates, firstweekday=ctx.obj["conf"]["locale"]["firstweekday"], encoding=ctx.obj["conf"]["locale"]["encoding"], locale=ctx.obj["conf"]["locale"], weeknumber=ctx.obj["conf"]["locale"]["weeknumbers"], show_all_days=ctx.obj["conf"]["default"]["show_all_days"], days=days or ctx.obj["conf"]["default"]["days"], events=events, ) @cli.command() @time_args @multi_calendar_option @click.pass_context def agenda(ctx, days, events, dates): """Print agenda.""" controllers.agenda( build_collection(ctx), date=dates, firstweekday=ctx.obj["conf"]["locale"]["firstweekday"], encoding=ctx.obj["conf"]["locale"]["encoding"], show_all_days=ctx.obj["conf"]["default"]["show_all_days"], locale=ctx.obj["conf"]["locale"], days=days or ctx.obj["conf"]["default"]["days"], events=events, ) @cli.command() @calendar_option @click.option("--location", "-l", help=("The location of the new event.")) @click.option( "--repeat", "-r", help=("Repeat event: daily, weekly, monthly or yearly.") ) @click.option("--until", "-u", help=("Stop an event repeating on this date.")) @click.argument("description", nargs=-1, required=True) @click.pass_context def new(ctx, calendar, description, location, repeat, until): """Create a new event.""" controllers.new_from_string( build_collection(ctx), calendar, ctx.obj["conf"], list(description), location=location, repeat=repeat, until=until.split(" ") if until is not None else None, ) @cli.command("import") @click.option( "--include-calendar", "-a", help=("The calendar to use."), expose_value=False, callback=_calendar_select_callback, metavar="CAL", ) @click.option("--batch", help=("do not ask for any confirmation."), is_flag=True) @click.option("--random_uid", "-r", help=("Select a random uid."), is_flag=True) @click.argument("ics", type=click.File("rb")) @click.pass_context def import_ics(ctx, ics, batch, random_uid): """Import events from an .ics file. If an event with the same UID is already present in the (implicitly) selected calendar import will ask before updating (i.e. overwriting) that old event with the imported one, unless --batch is given, than it will always update. If this behaviour is not desired, use the `--random-uid` flag to generate a new, random UID. If no calendar is specified (and not `--batch`), you will be asked to choose a calendar. You can either enter the number printed behind each calendar's name or any unique prefix of a calendar's name. """ ics_str = ics.read() controllers.import_ics( build_collection(ctx), ctx.obj["conf"], ics=ics_str, batch=batch, random_uid=random_uid, ) @cli.command() @multi_calendar_option @click.pass_context def interactive(ctx): """Interactive UI. Also launchable via `ikhal`.""" controllers.interactive(build_collection(ctx), ctx.obj["conf"]) @click.command() @multi_calendar_option @global_options @click.pass_context def interactive_cli(ctx, config, verbose): """Interactive UI. Also launchable via `khal interactive`.""" prepare_context(ctx, config, verbose) controllers.interactive(build_collection(ctx), ctx.obj["conf"]) @cli.command() @multi_calendar_option @click.pass_context def printcalendars(ctx): """List all calendars.""" click.echo("\n".join(build_collection(ctx).names)) @cli.command() @click.pass_context def printformats(ctx): """Print a date in all formats. Print the date 2013-12-21 10:09 in all configured date(time) formats to check if these locale settings are configured to ones liking.""" from datetime import datetime time = datetime(2013, 12, 21, 10, 9) for strftime_format in [ "longdatetimeformat", "datetimeformat", "longdateformat", "dateformat", "timeformat", ]: dt_str = time.strftime(ctx.obj["conf"]["locale"][strftime_format]) click.echo("{}: {}".format(strftime_format, dt_str)) @cli.command() @multi_calendar_option @click.argument("search_string") @click.pass_context def search(ctx, search_string): """Search for events matching SEARCH_STRING. For repetitive events only one event is currently shown. """ # TODO support for time ranges, location, description etc collection = build_collection(ctx) events = collection.search(search_string) event_column = list() term_width, _ = get_terminal_size() for event in events: desc = textwrap.wrap(event.event_description, term_width) event_column.extend([colored(d, event.color) for d in desc]) click.echo( to_unicode("\n".join(event_column), ctx.obj["conf"]["locale"]["encoding"]) ) @cli.command() @multi_calendar_option @click.argument("datetime", required=False, nargs=-1) @click.pass_context def at(ctx, datetime=None): """Show all events scheduled for DATETIME. if DATETIME is given (or the string `now`) all events scheduled for this moment are shown, if only a time is given, the date is assumed to be today """ collection = build_collection(ctx) locale = ctx.obj["conf"]["locale"] dtime_list = list(datetime) if dtime_list == [] or dtime_list == ["now"]: import datetime dtime = datetime.datetime.now() else: try: dtime, _ = aux.guessdatetimefstr(dtime_list, locale) except ValueError: logger.fatal( "{} is not a valid datetime (matches neither {} nor {} nor" " {})".format( " ".join(dtime_list), locale["timeformat"], locale["datetimeformat"], locale["longdatetimeformat"], ) ) sys.exit(1) dtime = locale["local_timezone"].localize(dtime) dtime = dtime.astimezone(pytz.UTC) events = collection.get_events_at(dtime) event_column = list() term_width, _ = get_terminal_size() for event in events: desc = textwrap.wrap(event.event_description, term_width) event_column.extend([colored(d, event.color) for d in desc]) click.echo( to_unicode("\n".join(event_column), ctx.obj["conf"]["locale"]["encoding"]) ) return cli, interactive_cli
https://github.com/pimutils/khal/issues/261
(vdir)gour@atmarama ~/p/vdir> ikhal -a gour Traceback (most recent call last): File "/home/gour/prj/vdir/bin/ikhal", line 9, in <module> load_entry_point('khal==0.6.1.dev83+nge9717c8', 'console_scripts', 'ikhal')() File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 700, in __call__ return self.main(*args, **kwargs) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 679, in main with self.make_context(prog_name, args, **extra) as ctx: File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 594, in make_context self.parse_args(ctx, args) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 858, in parse_args value, args = param.handle_parse_result(ctx, opts, args) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 1362, in handle_parse_result self.callback, ctx, self, value) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 56, in invoke_param_callback return callback(ctx, param, value) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/khal/cli.py", line 58, in _multi_calendar_select_callback if 'calendar_selection' in ctx.obj: TypeError: argument of type 'NoneType' is not iterable
TypeError
def cli(ctx): # setting the process title so it looks nicer in ps # shows up as 'khal' under linux and as 'python: khal (python2.7)' # under FreeBSD, which is still nicer than the default setproctitle("khal") if not ctx.invoked_subcommand: command = ctx.obj["conf"]["default"]["default_command"] if command: ctx.invoke(cli.commands[command]) else: click.echo(ctx.get_help()) ctx.exit(1)
def cli(ctx, config, verbose): # setting the process title so it looks nicer in ps # shows up as 'khal' under linux and as 'python: khal (python2.7)' # under FreeBSD, which is still nicer than the default setproctitle("khal") prepare_context(ctx, config, verbose) if not ctx.invoked_subcommand: command = ctx.obj["conf"]["default"]["default_command"] if command: ctx.invoke(cli.commands[command]) else: click.echo(ctx.get_help()) ctx.exit(1)
https://github.com/pimutils/khal/issues/261
(vdir)gour@atmarama ~/p/vdir> ikhal -a gour Traceback (most recent call last): File "/home/gour/prj/vdir/bin/ikhal", line 9, in <module> load_entry_point('khal==0.6.1.dev83+nge9717c8', 'console_scripts', 'ikhal')() File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 700, in __call__ return self.main(*args, **kwargs) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 679, in main with self.make_context(prog_name, args, **extra) as ctx: File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 594, in make_context self.parse_args(ctx, args) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 858, in parse_args value, args = param.handle_parse_result(ctx, opts, args) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 1362, in handle_parse_result self.callback, ctx, self, value) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 56, in invoke_param_callback return callback(ctx, param, value) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/khal/cli.py", line 58, in _multi_calendar_select_callback if 'calendar_selection' in ctx.obj: TypeError: argument of type 'NoneType' is not iterable
TypeError
def interactive_cli(ctx): """Interactive UI. Also launchable via `khal interactive`.""" controllers.interactive(build_collection(ctx), ctx.obj["conf"])
def interactive_cli(ctx, config, verbose): """Interactive UI. Also launchable via `khal interactive`.""" prepare_context(ctx, config, verbose) controllers.interactive(build_collection(ctx), ctx.obj["conf"])
https://github.com/pimutils/khal/issues/261
(vdir)gour@atmarama ~/p/vdir> ikhal -a gour Traceback (most recent call last): File "/home/gour/prj/vdir/bin/ikhal", line 9, in <module> load_entry_point('khal==0.6.1.dev83+nge9717c8', 'console_scripts', 'ikhal')() File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 700, in __call__ return self.main(*args, **kwargs) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 679, in main with self.make_context(prog_name, args, **extra) as ctx: File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 594, in make_context self.parse_args(ctx, args) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 858, in parse_args value, args = param.handle_parse_result(ctx, opts, args) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 1362, in handle_parse_result self.callback, ctx, self, value) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 56, in invoke_param_callback return callback(ctx, param, value) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/khal/cli.py", line 58, in _multi_calendar_select_callback if 'calendar_selection' in ctx.obj: TypeError: argument of type 'NoneType' is not iterable
TypeError
def import_event(vevent, collection, locale, batch, random_uid): """import one event into collection, let user choose the collection""" # print all sub-events for sub_event in vevent: if not batch: event = Event.fromVEvents( [sub_event], calendar=collection.default_calendar_name, locale=locale ) echo(event.event_description) # get the calendar to insert into if batch or len(collection.writable_names) == 1: calendar_name = collection.writable_names[0] else: choice = list() for num, name in enumerate(collection.writable_names): choice.append("{}({})".format(name, num)) choice = ", ".join(choice) while True: value = prompt( "Which calendar do you want to import to? \n{}".format(choice), default=collection.default_calendar_name, ) try: number = int(value) calendar_name = collection.writable_names[number] break except (ValueError, IndexError): matches = filter( lambda x: x.startswith(value), collection.writable_names ) if len(matches) == 1: calendar_name = matches[0] break echo("invalid choice") if batch or confirm( "Do you want to import this event into `{}`?".format(calendar_name) ): ics = aux.ics_from_list(vevent, random_uid) try: collection.new( Item(ics.to_ical().decode("utf-8")), collection=calendar_name ) except DuplicateUid: if batch or confirm( "An event with the same UID already exists. Do you want to update it?" ): collection.force_update( Item(ics.to_ical().decode("utf-8")), collection=calendar_name ) else: logger.warn("Not importing event with UID `{}`".format(event.uid))
def import_event(vevent, collection, locale, batch, random_uid): """import one event into collection, let user choose the collection""" # print all sub-events for sub_event in vevent: if not batch: event = Event.fromVEvents( [sub_event], calendar=collection.default_calendar_name, locale=locale ) echo(event.event_description) # get the calendar to insert into if batch or len(collection.writable_names) == 1: calendar_name = collection.default_calendar_name else: choice = list() for num, name in enumerate(collection.writable_names): choice.append("{}({})".format(name, num)) choice = ", ".join(choice) while True: value = prompt( "Which calendar do you want to import to? \n{}".format(choice), default=collection.default_calendar_name, ) try: number = int(value) calendar_name = collection.writable_names[number] break except (ValueError, IndexError): matches = filter( lambda x: x.startswith(value), collection.writable_names ) if len(matches) == 1: calendar_name = matches[0] break echo("invalid choice") if batch or confirm( "Do you want to import this event into `{}`?".format(calendar_name) ): ics = aux.ics_from_list(vevent, random_uid) try: collection.new( Item(ics.to_ical().decode("utf-8")), collection=calendar_name ) except DuplicateUid: if batch or confirm( "An event with the same UID already exists. Do you want to update it?" ): collection.force_update( Item(ics.to_ical().decode("utf-8")), collection=calendar_name ) else: logger.warn("Not importing event with UID `{}`".format(event.uid))
https://github.com/pimutils/khal/issues/253
(vdir)gour@atmarama ~/p/vdir> khal import -a gour ~/Downloads/gour-calendar.ics 03.09.2015: Krema vedske mudrosti <2015-09-03 Thu +2w> Repeat: FREQ=WEEKLY;INTERVAL=2 Do you want to import this event into `None`? [y/N]: y Traceback (most recent call last): File "/home/gour/prj/vdir/bin/khal", line 11, in <module> sys.exit(main_khal()) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 700, in __call__ return self.main(*args, **kwargs) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 680, in main rv = self.invoke(ctx) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 1027, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 873, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/core.py", line 508, in invoke return callback(*args, **kwargs) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/click/decorators.py", line 16, in new_func return f(get_current_context(), *args, **kwargs) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/khal/cli.py", line 298, in import_ics random_uid=random_uid File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/khal/controllers.py", line 216, in import_ics import_event(vevent, collection, conf['locale'], batch, random_uid) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/khal/controllers.py", line 257, in import_event collection=calendar_name) File "/home/gour/prj/vdir/local/lib/python2.7/site-packages/khal/khalendar/khalendar.py", line 330, in new self._calnames[event.calendar].new(event) AttributeError: 'Item' object has no attribute 'calendar'
AttributeError
def prepare_context(ctx, config, verbose): if ctx.obj is not None: return if verbose: logger.setLevel(logging.DEBUG) else: logger.setLevel(logging.INFO) ctx.obj = {} try: ctx.obj["conf"] = conf = get_config(config) except InvalidSettingsError: sys.exit(1) out = StringIO() conf.write(out) logger.debug("Using config:") logger.debug(out.getvalue()) if conf is None: raise click.UsageError("Invalid config file, exiting.")
def prepare_context(ctx, config, verbose): if ctx.obj is not None: return if verbose: logger.setLevel(logging.DEBUG) else: logger.setLevel(logging.INFO) ctx.obj = {} ctx.obj["conf"] = conf = get_config(config) out = StringIO() conf.write(out) logger.debug("Using config:") logger.debug(out.getvalue()) if conf is None: raise click.UsageError("Invalid config file, exiting.")
https://github.com/pimutils/khal/issues/109
Traceback (most recent call last): File "/usr/local/bin/khal", line 9, in <module> load_entry_point('khal==0.3.1', 'console_scripts', 'khal')() File "/usr/local/lib/python2.7/dist-packages/khal-0.3.1-py2.7.egg/khal/cli.py", line 104, in main_khal color=cal['color'], File "/usr/local/lib/python2.7/dist-packages/configobj-4.7.2-py2.7.egg/configobj.py", line 567, in __getitem__ val = dict.__getitem__(self, key) KeyError: 'color'
KeyError
def get_config(config_path=None): """reads the config file, validates it and return a config dict :param config_path: path to a custom config file, if none is given the default locations will be searched :type config_path: str :returns: configuration :rtype: dict """ if config_path is None: config_path = _find_configuration_file() logger.debug("using the config file at {}".format(config_path)) config = ConfigObj(DEFAULTSPATH, interpolation=False) try: user_config = ConfigObj( config_path, configspec=SPECPATH, interpolation=False, file_error=True, ) except ConfigObjError as error: logger.fatal( "parsing the config file file with the following error: {}".format(error) ) logger.fatal( "if you recently updated khal, the config file format " "might have changed, in that case please consult the " "CHANGELOG or other documentation" ) sys.exit(1) fdict = { "timezone": is_timezone, "expand_path": expand_path, "expand_db_path": expand_db_path, } validator = Validator(fdict) results = user_config.validate(validator, preserve_errors=True) abort = False for section, subsection, error in flatten_errors(config, results): abort = True if isinstance(error, Exception): logger.fatal( "config error:\nin [{}] {}: {}".format(section[0], subsection, error) ) else: for key in error: if isinstance(error[key], Exception): logger.fatal( "config error:\nin {} {}: {}".format( sectionize(section + [subsection]), key, str(error[key]) ) ) if abort or not results: raise InvalidSettingsError() config.merge(user_config) config_checks(config) extras = get_extra_values(user_config) for section, value in extras: if section == (): logger.warn('unknown section "{}" in config file'.format(value)) else: section = sectionize(section) logger.warn( 'unknown key or subsection "{}" in section "{}"'.format(value, section) ) return config
def get_config(config_path=None): """reads the config file, validates it and return a config dict :param config_path: path to a custom config file, if none is given the default locations will be searched :type config_path: str :returns: configuration :rtype: dict """ if config_path is None: config_path = _find_configuration_file() logger.debug("using the config file at {}".format(config_path)) config = ConfigObj(DEFAULTSPATH, interpolation=False) try: user_config = ConfigObj( config_path, configspec=SPECPATH, interpolation=False, file_error=True, ) except ConfigObjError as error: logger.fatal( "parsing the config file file with the following error: {}".format(error) ) logger.fatal( "if you recently updated khal, the config file format " "might have changed, in that case please consult the " "CHANGELOG or other documentation" ) sys.exit(1) fdict = { "timezone": is_timezone, "expand_path": expand_path, } validator = Validator(fdict) results = user_config.validate(validator, preserve_errors=True) if not results: for entry in flatten_errors(config, results): # each entry is a tuple section_list, key, error = entry if key is not None: section_list.append(key) else: section_list.append("[missing section]") section_string = ", ".join(section_list) if error is False: error = "Missing value or section." print(section_string, " = ", error) raise ValueError # TODO own error class config.merge(user_config) config_checks(config) extras = get_extra_values(user_config) for section, value in extras: if section == (): logger.warn('unknown section "{}" in config file'.format(value)) else: section = sectionize(section) logger.warn( 'unknown key or subsection "{}" in section "{}"'.format(value, section) ) return config
https://github.com/pimutils/khal/issues/109
Traceback (most recent call last): File "/usr/local/bin/khal", line 9, in <module> load_entry_point('khal==0.3.1', 'console_scripts', 'khal')() File "/usr/local/lib/python2.7/dist-packages/khal-0.3.1-py2.7.egg/khal/cli.py", line 104, in main_khal color=cal['color'], File "/usr/local/lib/python2.7/dist-packages/configobj-4.7.2-py2.7.egg/configobj.py", line 567, in __getitem__ val = dict.__getitem__(self, key) KeyError: 'color'
KeyError
def config_checks(config): """do some tests on the config we cannot do with configobj's validator""" if len(config["calendars"].keys()) < 1: logger.fatal("Found no calendar section in the config file") raise InvalidSettingsError() test_default_calendar(config) config["sqlite"]["path"] = expand_db_path(config["sqlite"]["path"]) if not config["locale"]["default_timezone"]: config["locale"]["default_timezone"] = is_timezone( config["locale"]["default_timezone"] ) if not config["locale"]["local_timezone"]: config["locale"]["local_timezone"] = is_timezone( config["locale"]["local_timezone"] )
def config_checks(config): """do some tests on the config we cannot do with configobj's validator""" if len(config["calendars"].keys()) < 1: raise ValueError("Found no calendar in the config file") test_default_calendar(config) config["sqlite"]["path"] = expand_db_path(config["sqlite"]["path"]) if not config["locale"]["default_timezone"]: config["locale"]["default_timezone"] = is_timezone( config["locale"]["default_timezone"] ) if not config["locale"]["local_timezone"]: config["locale"]["local_timezone"] = is_timezone( config["locale"]["local_timezone"] )
https://github.com/pimutils/khal/issues/109
Traceback (most recent call last): File "/usr/local/bin/khal", line 9, in <module> load_entry_point('khal==0.3.1', 'console_scripts', 'khal')() File "/usr/local/lib/python2.7/dist-packages/khal-0.3.1-py2.7.egg/khal/cli.py", line 104, in main_khal color=cal['color'], File "/usr/local/lib/python2.7/dist-packages/configobj-4.7.2-py2.7.egg/configobj.py", line 567, in __getitem__ val = dict.__getitem__(self, key) KeyError: 'color'
KeyError
def expand(vevent, default_tz, href=""): """ :param vevent: vevent to be expanded :type vevent: icalendar.cal.Event :param default_tz: the default timezone used when we (icalendar) don't understand the embedded timezone :type default_tz: pytz.timezone :param href: the href of the vevent, used for more informative logging :type href: str :returns: list of start and end (date)times of the expanded event :rtyped list(tuple(datetime, datetime)) """ # we do this now and than never care about the "real" end time again if "DURATION" in vevent: duration = vevent["DURATION"].dt else: duration = vevent["DTEND"].dt - vevent["DTSTART"].dt # dateutil.rrule converts everything to datetime allday = True if not isinstance(vevent["DTSTART"].dt, datetime) else False # icalendar did not understand the defined timezone if ( not allday and "TZID" in vevent["DTSTART"].params and vevent["DTSTART"].dt.tzinfo is None ): vevent["DTSTART"].dt = default_tz.localize(vevent["DTSTART"].dt) if "RRULE" not in vevent.keys(): return [(vevent["DTSTART"].dt, vevent["DTSTART"].dt + duration)] events_tz = None if ( hasattr(vevent["DTSTART"].dt, "tzinfo") and vevent["DTSTART"].dt.tzinfo is not None ): events_tz = vevent["DTSTART"].dt.tzinfo vevent["DTSTART"].dt = vevent["DTSTART"].dt.astimezone(pytz.UTC) rrulestr = vevent["RRULE"].to_ical() rrule = dateutil.rrule.rrulestr(rrulestr, dtstart=vevent["DTSTART"].dt) if not set(["UNTIL", "COUNT"]).intersection(vevent["RRULE"].keys()): # rrule really doesn't like to calculate all recurrences until # eternity, so we only do it 15years into the future rrule._until = vevent["DTSTART"].dt + timedelta(days=15 * 365) if ( rrule._until is not None and rrule._until.tzinfo is None and vevent["DTSTART"].dt.tzinfo is not None ): rrule._until = vevent["DTSTART"].dt.tzinfo.localize(rrule._until) logging.debug( "calculating recurrence dates for {0}, this might take some time.".format(href) ) dtstartl = list(rrule) if len(dtstartl) == 0: raise UnsupportedRecursion if events_tz is not None: dtstartl = [start.astimezone(events_tz) for start in dtstartl] elif allday: dtstartl = [start.date() for start in dtstartl] dtstartend = [(start, start + duration) for start in dtstartl] return dtstartend
def expand(vevent, default_tz, href=""): """ :param vevent: vevent to be expanded :type vevent: icalendar.cal.Event :param default_tz: the default timezone used when we (icalendar) don't understand the embedded timezone :type default_tz: pytz.timezone :param href: the href of the vevent, used for more informative logging :type href: str :returns: list of start and end (date)times of the expanded event :rtyped list(tuple(datetime, datetime)) """ # we do this now and than never care about the "real" end time again if "DURATION" in vevent: duration = vevent["DURATION"].dt else: duration = vevent["DTEND"].dt - vevent["DTSTART"].dt # icalendar did not understand the defined timezone if "TZID" in vevent["DTSTART"].params and vevent["DTSTART"].dt.tzinfo is None: vevent["DTSTART"].dt = default_tz.localize(vevent["DTSTART"].dt) if "RRULE" not in vevent.keys(): return [(vevent["DTSTART"].dt, vevent["DTSTART"].dt + duration)] events_tz = None if ( hasattr(vevent["DTSTART"].dt, "tzinfo") and vevent["DTSTART"].dt.tzinfo is not None ): events_tz = vevent["DTSTART"].dt.tzinfo vevent["DTSTART"].dt = vevent["DTSTART"].dt.astimezone(pytz.UTC) # dateutil.rrule converts everything to datetime allday = True if not isinstance(vevent["DTSTART"].dt, datetime) else False rrulestr = vevent["RRULE"].to_ical() rrule = dateutil.rrule.rrulestr(rrulestr, dtstart=vevent["DTSTART"].dt) if not set(["UNTIL", "COUNT"]).intersection(vevent["RRULE"].keys()): # rrule really doesn't like to calculate all recurrences until # eternity, so we only do it 15years into the future rrule._until = vevent["DTSTART"].dt + timedelta(days=15 * 365) if ( rrule._until is not None and rrule._until.tzinfo is None and vevent["DTSTART"].dt.tzinfo is not None ): rrule._until = vevent["DTSTART"].dt.tzinfo.localize(rrule._until) logging.debug( "calculating recurrence dates for {0}, this might take some time.".format(href) ) dtstartl = list(rrule) if len(dtstartl) == 0: raise UnsupportedRecursion if events_tz is not None: dtstartl = [start.astimezone(events_tz) for start in dtstartl] elif allday: dtstartl = [start.date() for start in dtstartl] dtstartend = [(start, start + duration) for start in dtstartl] return dtstartend
https://github.com/pimutils/khal/issues/60
jason@valis:~> khal --sync Traceback (most recent call last): File "/usr/bin/khal", line 5, in <module> pkg_resources.run_script('khal==0.2.0.dev-62-g2c8baea', 'khal') File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 499, in run_script self.require(requires)[0].run_script(script_name, ns) File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 1255, in run_script execfile(script_filename, namespace, namespace) File "/usr/lib/python2.7/site-packages/khal-0.2.0.dev_62_g2c8baea-py2.7.egg/EGG-INFO/scripts/khal", line 74, in <module> default_tz=conf.default.default_timezone File "/usr/lib/python2.7/site-packages/khal-0.2.0.dev_62_g2c8baea-py2.7.egg/khal/khalendar/khalendar.py", line 82, in __init__ self.db_update() File "/usr/lib/python2.7/site-packages/khal-0.2.0.dev_62_g2c8baea-py2.7.egg/khal/khalendar/khalendar.py", line 160, in db_update self.update_vevent(href) File "/usr/lib/python2.7/site-packages/khal-0.2.0.dev_62_g2c8baea-py2.7.egg/khal/khalendar/khalendar.py", line 166, in update_vevent ignore_invalid_items=True) File "/usr/lib/python2.7/site-packages/khal-0.2.0.dev_62_g2c8baea-py2.7.egg/khal/khalendar/backend.py", line 279, in update href) File "/usr/lib/python2.7/site-packages/khal-0.2.0.dev_62_g2c8baea-py2.7.egg/khal/khalendar/datetimehelper.py", line 35, in expand vevent['DTSTART'].dt.tzinfo is None): AttributeError: 'datetime.date' object has no attribute 'tzinfo'
AttributeError
def expand(vevent, default_tz, href=""): """ :param vevent: vevent to be expanded :type vevent: icalendar.cal.Event :param default_tz: the default timezone used when we (icalendar) don't understand the embedded timezone :type default_tz: pytz.timezone :param href: the href of the vevent, used for more informative logging :type href: str :returns: list of start and end (date)times of the expanded event :rtyped list(tuple(datetime, datetime)) """ # we do this now and than never care about the "real" end time again if "DURATION" in vevent: duration = vevent["DURATION"].dt else: duration = vevent["DTEND"].dt - vevent["DTSTART"].dt # dateutil.rrule converts everything to datetime allday = True if not isinstance(vevent["DTSTART"].dt, datetime) else False # icalendar did not understand the defined timezone if ( not allday and "TZID" in vevent["DTSTART"].params and vevent["DTSTART"].dt.tzinfo is None ): vevent["DTSTART"].dt = default_tz.localize(vevent["DTSTART"].dt) if "RRULE" not in vevent.keys(): return [(vevent["DTSTART"].dt, vevent["DTSTART"].dt + duration)] events_tz = None if getattr(vevent["DTSTART"].dt, "tzinfo", False): events_tz = vevent["DTSTART"].dt.tzinfo vevent["DTSTART"].dt = vevent["DTSTART"].dt.astimezone(pytz.UTC) rrulestr = vevent["RRULE"].to_ical() rrule = dateutil.rrule.rrulestr(rrulestr, dtstart=vevent["DTSTART"].dt) if not set(["UNTIL", "COUNT"]).intersection(vevent["RRULE"].keys()): # rrule really doesn't like to calculate all recurrences until # eternity, so we only do it 15years into the future rrule._until = vevent["DTSTART"].dt + timedelta(days=15 * 365) if (not getattr(rrule._until, "tzinfo", True)) and ( not getattr(vevent["DTSTART"].dt, "tzinfo", True) ): rrule._until = vevent["DTSTART"].dt.tzinfo.localize(rrule._until) logging.debug( "calculating recurrence dates for {0}, this might take some time.".format(href) ) dtstartl = list(rrule) if len(dtstartl) == 0: raise UnsupportedRecursion if events_tz is not None: dtstartl = [start.astimezone(events_tz) for start in dtstartl] elif allday: dtstartl = [start.date() for start in dtstartl] dtstartend = [(start, start + duration) for start in dtstartl] return dtstartend
def expand(vevent, default_tz, href=""): """ :param vevent: vevent to be expanded :type vevent: icalendar.cal.Event :param default_tz: the default timezone used when we (icalendar) don't understand the embedded timezone :type default_tz: pytz.timezone :param href: the href of the vevent, used for more informative logging :type href: str :returns: list of start and end (date)times of the expanded event :rtyped list(tuple(datetime, datetime)) """ # we do this now and than never care about the "real" end time again if "DURATION" in vevent: duration = vevent["DURATION"].dt else: duration = vevent["DTEND"].dt - vevent["DTSTART"].dt # dateutil.rrule converts everything to datetime allday = True if not isinstance(vevent["DTSTART"].dt, datetime) else False # icalendar did not understand the defined timezone if ( not allday and "TZID" in vevent["DTSTART"].params and vevent["DTSTART"].dt.tzinfo is None ): vevent["DTSTART"].dt = default_tz.localize(vevent["DTSTART"].dt) if "RRULE" not in vevent.keys(): return [(vevent["DTSTART"].dt, vevent["DTSTART"].dt + duration)] events_tz = None if ( hasattr(vevent["DTSTART"].dt, "tzinfo") and vevent["DTSTART"].dt.tzinfo is not None ): events_tz = vevent["DTSTART"].dt.tzinfo vevent["DTSTART"].dt = vevent["DTSTART"].dt.astimezone(pytz.UTC) rrulestr = vevent["RRULE"].to_ical() rrule = dateutil.rrule.rrulestr(rrulestr, dtstart=vevent["DTSTART"].dt) if not set(["UNTIL", "COUNT"]).intersection(vevent["RRULE"].keys()): # rrule really doesn't like to calculate all recurrences until # eternity, so we only do it 15years into the future rrule._until = vevent["DTSTART"].dt + timedelta(days=15 * 365) if ( rrule._until is not None and rrule._until.tzinfo is None and vevent["DTSTART"].dt.tzinfo is not None ): rrule._until = vevent["DTSTART"].dt.tzinfo.localize(rrule._until) logging.debug( "calculating recurrence dates for {0}, this might take some time.".format(href) ) dtstartl = list(rrule) if len(dtstartl) == 0: raise UnsupportedRecursion if events_tz is not None: dtstartl = [start.astimezone(events_tz) for start in dtstartl] elif allday: dtstartl = [start.date() for start in dtstartl] dtstartend = [(start, start + duration) for start in dtstartl] return dtstartend
https://github.com/pimutils/khal/issues/60
jason@valis:~> khal --sync Traceback (most recent call last): File "/usr/bin/khal", line 5, in <module> pkg_resources.run_script('khal==0.2.0.dev-62-g2c8baea', 'khal') File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 499, in run_script self.require(requires)[0].run_script(script_name, ns) File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 1255, in run_script execfile(script_filename, namespace, namespace) File "/usr/lib/python2.7/site-packages/khal-0.2.0.dev_62_g2c8baea-py2.7.egg/EGG-INFO/scripts/khal", line 74, in <module> default_tz=conf.default.default_timezone File "/usr/lib/python2.7/site-packages/khal-0.2.0.dev_62_g2c8baea-py2.7.egg/khal/khalendar/khalendar.py", line 82, in __init__ self.db_update() File "/usr/lib/python2.7/site-packages/khal-0.2.0.dev_62_g2c8baea-py2.7.egg/khal/khalendar/khalendar.py", line 160, in db_update self.update_vevent(href) File "/usr/lib/python2.7/site-packages/khal-0.2.0.dev_62_g2c8baea-py2.7.egg/khal/khalendar/khalendar.py", line 166, in update_vevent ignore_invalid_items=True) File "/usr/lib/python2.7/site-packages/khal-0.2.0.dev_62_g2c8baea-py2.7.egg/khal/khalendar/backend.py", line 279, in update href) File "/usr/lib/python2.7/site-packages/khal-0.2.0.dev_62_g2c8baea-py2.7.egg/khal/khalendar/datetimehelper.py", line 35, in expand vevent['DTSTART'].dt.tzinfo is None): AttributeError: 'datetime.date' object has no attribute 'tzinfo'
AttributeError
def update(self, vevent, account, href="", etag="", status=OK): """insert a new or update an existing card in the db This is mostly a wrapper around two SQL statements, doing some cleanup before. :param vcard: vcard to be inserted or updated :type vcard: unicode :param href: href of the card on the server, if this href already exists in the db the card gets updated. If no href is given, a random href is chosen and it is implied that this card does not yet exist on the server, but will be uploaded there on next sync. :type href: str() :param etag: the etga of the vcard, if this etag does not match the remote etag on next sync, this card will be updated from the server. For locally created vcards this should not be set :type etag: str() :param status: status of the vcard * OK: card is in sync with remote server * NEW: card is not yet on the server, this needs to be set for locally created vcards * CHANGED: card locally changed, will be updated on the server on next sync (if remote card has not changed since last sync) * DELETED: card locally delete, will also be deleted on one the server on next sync (if remote card has not changed) :type status: one of backend.OK, backend.NEW, backend.CHANGED, backend.DELETED """ self._check_account(account) if not isinstance(vevent, icalendar.cal.Event): ical = icalendar.Event.from_ical(vevent) for component in ical.walk(): if component.name == "VEVENT": vevent = component all_day_event = False if href == "" or href is None: href = get_random_href() if "VALUE" in vevent["DTSTART"].params: if vevent["DTSTART"].params["VALUE"] == "DATE": all_day_event = True dtstart = vevent["DTSTART"].dt if "RRULE" in vevent.keys(): rrulestr = vevent["RRULE"].to_ical() rrule = dateutil.rrule.rrulestr(rrulestr, dtstart=dtstart) today = datetime.datetime.today() if hasattr(dtstart, "tzinfo") and dtstart.tzinfo is not None: # would be better to check if self is all day event today = self.conf.default.default_timezone.localize(today) if not set(["UNTIL", "COUNT"]).intersection(vevent["RRULE"].keys()): # rrule really doesn't like to calculate all recurrences until # eternity rrule._until = today + datetime.timedelta(days=15 * 365) logging.debug( "calculating recurrence dates for {0}, this might take some time.".format( href ) ) dtstartl = list(rrule) if len(dtstartl) == 0: raise UpdateFailed( "Unsupported recursion rule for event {0}:\n{1}".format( href, vevent.to_ical() ) ) if "DURATION" in vevent.keys(): duration = vevent["DURATION"].dt else: duration = vevent["DTEND"].dt - vevent["DTSTART"].dt dtstartend = [(start, start + duration) for start in dtstartl] else: if "DTEND" in vevent.keys(): dtend = vevent["DTEND"].dt else: dtend = vevent["DTSTART"].dt + vevent["DURATION"].dt dtstartend = [(dtstart, dtend)] for dbname in [account + "_d", account + "_dt"]: sql_s = "DELETE FROM {0} WHERE href == ?".format(dbname) self.sql_ex(sql_s, (href,), commit=False) for dtstart, dtend in dtstartend: if all_day_event: dbstart = dtstart.strftime("%Y%m%d") dbend = dtend.strftime("%Y%m%d") dbname = account + "_d" else: # TODO: extract strange (aka non Olson) TZs from params['TZID'] # perhaps better done in event/vevent if dtstart.tzinfo is None: dtstart = self.conf.default.default_timezone.localize(dtstart) if dtend.tzinfo is None: dtend = self.conf.default.default_timezone.localize(dtend) dtstart_utc = dtstart.astimezone(pytz.UTC) dtend_utc = dtend.astimezone(pytz.UTC) dbstart = calendar.timegm(dtstart_utc.timetuple()) dbend = calendar.timegm(dtend_utc.timetuple()) dbname = account + "_dt" sql_s = "INSERT INTO {0} (dtstart, dtend, href) VALUES (?, ?, ?);".format( dbname ) stuple = (dbstart, dbend, href) self.sql_ex(sql_s, stuple, commit=False) sql_s = ( "INSERT OR REPLACE INTO {0} " "(status, vevent, etag, href) " "VALUES (?, ?, ?, " "COALESCE((SELECT href FROM {0} WHERE href = ?), ?)" ");".format(account + "_m") ) stuple = (status, vevent.to_ical().decode("utf-8"), etag, href, href) self.sql_ex(sql_s, stuple, commit=False) self.conn.commit()
def update(self, vevent, account, href="", etag="", status=OK): """insert a new or update an existing card in the db This is mostly a wrapper around two SQL statements, doing some cleanup before. :param vcard: vcard to be inserted or updated :type vcard: unicode :param href: href of the card on the server, if this href already exists in the db the card gets updated. If no href is given, a random href is chosen and it is implied that this card does not yet exist on the server, but will be uploaded there on next sync. :type href: str() :param etag: the etga of the vcard, if this etag does not match the remote etag on next sync, this card will be updated from the server. For locally created vcards this should not be set :type etag: str() :param status: status of the vcard * OK: card is in sync with remote server * NEW: card is not yet on the server, this needs to be set for locally created vcards * CHANGED: card locally changed, will be updated on the server on next sync (if remote card has not changed since last sync) * DELETED: card locally delete, will also be deleted on one the server on next sync (if remote card has not changed) :type status: one of backend.OK, backend.NEW, backend.CHANGED, backend.DELETED """ self._check_account(account) if not isinstance(vevent, icalendar.cal.Event): ical = icalendar.Event.from_ical(vevent) for component in ical.walk(): if component.name == "VEVENT": vevent = component all_day_event = False if href == "" or href is None: href = get_random_href() if "VALUE" in vevent["DTSTART"].params: if vevent["DTSTART"].params["VALUE"] == "DATE": all_day_event = True dtstart = vevent["DTSTART"].dt if "RRULE" in vevent.keys(): rrulestr = vevent["RRULE"].to_ical() rrule = dateutil.rrule.rrulestr(rrulestr, dtstart=dtstart) today = datetime.datetime.today() if hasattr(dtstart, "tzinfo") and dtstart.tzinfo is not None: # would be better to check if self is all day event today = self.conf.default.default_timezone.localize(today) if not set(["UNTIL", "COUNT"]).intersection(vevent["RRULE"].keys()): # rrule really doesn't like to calculate all recurrences until # eternity rrule._until = today + datetime.timedelta(days=15 * 365) logging.debug( "calculating recurrence dates for {0}, this might take some time.".format( href ) ) dtstartl = list(rrule) if len(dtstartl) == 0: raise UpdateFailed( "Unsupported recursion rule for event {0}:\n{1}".format( href, vevent.to_ical() ) ) if "DURATION" in vevent.keys(): duration = vevent["DURATION"].dt else: duration = vevent["DTEND"].dt - vevent["DTSTART"].dt dtstartend = [(start, start + duration) for start in dtstartl] else: if "DTEND" in vevent.keys(): dtend = vevent["DTEND"].dt else: dtend = vevent["DTSTART"].dt + vevent["DURATION"].dt dtstartend = [(dtstart, dtend)] for dbname in [account + "_d", account + "_dt"]: sql_s = "DELETE FROM {0} WHERE href == ?".format(dbname) self.sql_ex(sql_s, (href,), commit=False) for dtstart, dtend in dtstartend: if all_day_event: dbstart = dtstart.strftime("%Y%m%d") dbend = dtend.strftime("%Y%m%d") dbname = account + "_d" else: # TODO: extract strange (aka non Olson) TZs from params['TZID'] # perhaps better done in model/vevent if dtstart.tzinfo is None: dtstart = self.conf.default.default_timezone.localize(dtstart) if dtend.tzinfo is None: dtend = self.conf.default.default_timezone.localize(dtend) dtstart_utc = dtstart.astimezone(pytz.UTC) dtend_utc = dtend.astimezone(pytz.UTC) dbstart = calendar.timegm(dtstart_utc.timetuple()) dbend = calendar.timegm(dtend_utc.timetuple()) dbname = account + "_dt" sql_s = "INSERT INTO {0} (dtstart, dtend, href) VALUES (?, ?, ?);".format( dbname ) stuple = (dbstart, dbend, href) self.sql_ex(sql_s, stuple, commit=False) sql_s = ( "INSERT OR REPLACE INTO {0} " "(status, vevent, etag, href) " "VALUES (?, ?, ?, " "COALESCE((SELECT href FROM {0} WHERE href = ?), ?)" ");".format(account + "_m") ) stuple = (status, vevent.to_ical().decode("utf-8"), etag, href, href) self.sql_ex(sql_s, stuple, commit=False) self.conn.commit()
https://github.com/pimutils/khal/issues/23
Traceback (most recent call last): File "/usr/local/bin/khal", line 5, in <module> pkg_resources.run_script('khal==0.1.0.dev', 'khal') File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 540, in run_script self.require(requires)[0].run_script(script_name, ns) File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 1462, in run_script exec_(script_code, namespace, namespace) File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 41, in exec_ exec("""exec code in globs, locs""") File "<string>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/khal-0.1.0.dev-py2.7.egg/EGG-INFO/scripts/khal", line 27, in <module> File "build/bdist.linux-x86_64/egg/khal/controllers.py", line 31, in <module> File "build/bdist.linux-x86_64/egg/khal/backend.py", line 80, in <module> ImportError: No module named model
ImportError
def __init__(self, conf): db_path = conf.sqlite.path if db_path is None: db_path = xdg.BaseDirectory.save_data_path("khal") + "/khal.db" self.db_path = path.expanduser(db_path) self.conn = sqlite3.connect(self.db_path) self.cursor = self.conn.cursor() self.debug = conf.debug self._create_default_tables() self._check_table_version() self.conf = conf self._accounts = []
def __init__(self, conf): db_path = conf.sqlite.path if db_path is None: db_path = xdg.BaseDirectory.save_data_path("khal") + "/khal.db" self.db_path = path.expanduser(db_path) self.conn = sqlite3.connect(self.db_path) self.cursor = self.conn.cursor() self.debug = conf.debug self._create_default_tables() self._check_table_version() self.conf = conf
https://github.com/pimutils/khal/issues/7
Traceback (most recent call last): File "/home/catern/src/khal/virt/bin/khal", line 5, in <module> pkg_resources.run_script('khal==0.1.0.dev', 'khal') File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script self.require(requires)[0].run_script(script_name, ns) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 1462, in run_script exec_(script_code, namespace, namespace) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 41, in exec_ exec("""exec code in globs, locs""") File "<string>", line 1, in <module> File "/home/catern/src/khal/virt/lib/python2.7/site-packages/khal-0.1.0.dev-py2.7.egg/EGG-INFO/scripts/khal", line 72, in <module> File "build/bdist.linux-x86_64/egg/khal/controllers.py", line 178, in __init__ File "build/bdist.linux-x86_64/egg/khal/backend.py", line 440, in get_allday_range File "build/bdist.linux-x86_64/egg/khal/backend.py", line 164, in sql_ex sqlite3.OperationalError: no such table: simple_d
sqlite3.OperationalError
def needs_update(self, account, href_etag_list): """checks if we need to update this vcard :param account: account :param account: string :param href_etag_list: list of tuples of (hrefs and etags) :return: list of hrefs that need an update """ self._check_account(account) needs_update = list() for href, etag in href_etag_list: stuple = (href,) sql_s = "SELECT etag FROM {0} WHERE href = ?".format(account + "_m") result = self.sql_ex(sql_s, stuple) if not result or etag != result[0][0]: needs_update.append(href) return needs_update
def needs_update(self, account, href_etag_list): """checks if we need to update this vcard :param account: account :param account: string :param href_etag_list: list of tuples of (hrefs and etags) :return: list of hrefs that need an update """ needs_update = list() for href, etag in href_etag_list: stuple = (href,) sql_s = "SELECT etag FROM {0} WHERE href = ?".format(account + "_m") result = self.sql_ex(sql_s, stuple) if not result or etag != result[0][0]: needs_update.append(href) return needs_update
https://github.com/pimutils/khal/issues/7
Traceback (most recent call last): File "/home/catern/src/khal/virt/bin/khal", line 5, in <module> pkg_resources.run_script('khal==0.1.0.dev', 'khal') File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script self.require(requires)[0].run_script(script_name, ns) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 1462, in run_script exec_(script_code, namespace, namespace) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 41, in exec_ exec("""exec code in globs, locs""") File "<string>", line 1, in <module> File "/home/catern/src/khal/virt/lib/python2.7/site-packages/khal-0.1.0.dev-py2.7.egg/EGG-INFO/scripts/khal", line 72, in <module> File "build/bdist.linux-x86_64/egg/khal/controllers.py", line 178, in __init__ File "build/bdist.linux-x86_64/egg/khal/backend.py", line 440, in get_allday_range File "build/bdist.linux-x86_64/egg/khal/backend.py", line 164, in sql_ex sqlite3.OperationalError: no such table: simple_d
sqlite3.OperationalError
def update(self, vevent, account, href="", etag="", status=OK): """insert a new or update an existing card in the db This is mostly a wrapper around two SQL statements, doing some cleanup before. :param vcard: vcard to be inserted or updated :type vcard: unicode :param href: href of the card on the server, if this href already exists in the db the card gets updated. If no href is given, a random href is chosen and it is implied that this card does not yet exist on the server, but will be uploaded there on next sync. :type href: str() :param etag: the etga of the vcard, if this etag does not match the remote etag on next sync, this card will be updated from the server. For locally created vcards this should not be set :type etag: str() :param status: status of the vcard * OK: card is in sync with remote server * NEW: card is not yet on the server, this needs to be set for locally created vcards * CHANGED: card locally changed, will be updated on the server on next sync (if remote card has not changed since last sync) * DELETED: card locally delete, will also be deleted on one the server on next sync (if remote card has not changed) :type status: one of backend.OK, backend.NEW, backend.CHANGED, backend.DELETED """ self._check_account(account) if not isinstance(vevent, icalendar.cal.Event): ical = icalendar.Event.from_ical(vevent) for component in ical.walk(): if component.name == "VEVENT": vevent = component all_day_event = False if href == "" or href is None: href = get_random_href() if "VALUE" in vevent["DTSTART"].params: if vevent["DTSTART"].params["VALUE"] == "DATE": all_day_event = True dtstart = vevent["DTSTART"].dt if "RRULE" in vevent.keys(): rrulestr = vevent["RRULE"].to_ical() rrule = dateutil.rrule.rrulestr(rrulestr, dtstart=dtstart) today = datetime.datetime.today() if hasattr(dtstart, "tzinfo") and dtstart.tzinfo is not None: # would be better to check if self is all day event today = self.conf.default.default_timezone.localize(today) rrule._until = today + datetime.timedelta(days=15 * 365) logging.debug( "calculating recurrence dates for {0}, this might take some time.".format( href ) ) dtstartl = list(rrule) if len(dtstartl) == 0: raise UpdateFailed( "Unsupported recursion rule for event {0}:\n{1}".format( href, vevent.to_ical() ) ) if "DURATION" in vevent.keys(): duration = vevent["DURATION"].dt else: duration = vevent["DTEND"].dt - vevent["DTSTART"].dt dtstartend = [(start, start + duration) for start in dtstartl] else: if "DTEND" in vevent.keys(): dtend = vevent["DTEND"].dt else: dtend = vevent["DTSTART"].dt + vevent["DURATION"].dt dtstartend = [(dtstart, dtend)] for dbname in [account + "_d", account + "_dt"]: sql_s = "DELETE FROM {0} WHERE href == ?".format(dbname) self.sql_ex(sql_s, (href,), commit=False) for dtstart, dtend in dtstartend: if all_day_event: dbstart = dtstart.strftime("%Y%m%d") dbend = dtend.strftime("%Y%m%d") dbname = account + "_d" else: # TODO: extract strange (aka non Olson) TZs from params['TZID'] # perhaps better done in model/vevent if dtstart.tzinfo is None: dtstart = self.conf.default.default_timezone.localize(dtstart) if dtend.tzinfo is None: dtend = self.conf.default.default_timezone.localize(dtend) dtstart_utc = dtstart.astimezone(pytz.UTC) dtend_utc = dtend.astimezone(pytz.UTC) dbstart = calendar.timegm(dtstart_utc.timetuple()) dbend = calendar.timegm(dtend_utc.timetuple()) dbname = account + "_dt" sql_s = "INSERT INTO {0} (dtstart, dtend, href) VALUES (?, ?, ?);".format( dbname ) stuple = (dbstart, dbend, href) self.sql_ex(sql_s, stuple, commit=False) sql_s = ( "INSERT OR REPLACE INTO {0} " "(status, vevent, etag, href) " "VALUES (?, ?, ?, " "COALESCE((SELECT href FROM {0} WHERE href = ?), ?)" ");".format(account + "_m") ) stuple = (status, vevent.to_ical().decode("utf-8"), etag, href, href) self.sql_ex(sql_s, stuple, commit=False) self.conn.commit()
def update(self, vevent, account, href="", etag="", status=OK): """insert a new or update an existing card in the db This is mostly a wrapper around two SQL statements, doing some cleanup before. :param vcard: vcard to be inserted or updated :type vcard: unicode :param href: href of the card on the server, if this href already exists in the db the card gets updated. If no href is given, a random href is chosen and it is implied that this card does not yet exist on the server, but will be uploaded there on next sync. :type href: str() :param etag: the etga of the vcard, if this etag does not match the remote etag on next sync, this card will be updated from the server. For locally created vcards this should not be set :type etag: str() :param status: status of the vcard * OK: card is in sync with remote server * NEW: card is not yet on the server, this needs to be set for locally created vcards * CHANGED: card locally changed, will be updated on the server on next sync (if remote card has not changed since last sync) * DELETED: card locally delete, will also be deleted on one the server on next sync (if remote card has not changed) :type status: one of backend.OK, backend.NEW, backend.CHANGED, backend.DELETED """ if not isinstance(vevent, icalendar.cal.Event): ical = icalendar.Event.from_ical(vevent) for component in ical.walk(): if component.name == "VEVENT": vevent = component all_day_event = False if href == "" or href is None: href = get_random_href() if "VALUE" in vevent["DTSTART"].params: if vevent["DTSTART"].params["VALUE"] == "DATE": all_day_event = True dtstart = vevent["DTSTART"].dt if "RRULE" in vevent.keys(): rrulestr = vevent["RRULE"].to_ical() rrule = dateutil.rrule.rrulestr(rrulestr, dtstart=dtstart) today = datetime.datetime.today() if hasattr(dtstart, "tzinfo") and dtstart.tzinfo is not None: # would be better to check if self is all day event today = self.conf.default.default_timezone.localize(today) rrule._until = today + datetime.timedelta(days=15 * 365) logging.debug( "calculating recurrence dates for {0}, this might take some time.".format( href ) ) dtstartl = list(rrule) if len(dtstartl) == 0: raise UpdateFailed( "Unsupported recursion rule for event {0}:\n{1}".format( href, vevent.to_ical() ) ) if "DURATION" in vevent.keys(): duration = vevent["DURATION"].dt else: duration = vevent["DTEND"].dt - vevent["DTSTART"].dt dtstartend = [(start, start + duration) for start in dtstartl] else: if "DTEND" in vevent.keys(): dtend = vevent["DTEND"].dt else: dtend = vevent["DTSTART"].dt + vevent["DURATION"].dt dtstartend = [(dtstart, dtend)] for dbname in [account + "_d", account + "_dt"]: sql_s = "DELETE FROM {0} WHERE href == ?".format(dbname) self.sql_ex(sql_s, (href,), commit=False) for dtstart, dtend in dtstartend: if all_day_event: dbstart = dtstart.strftime("%Y%m%d") dbend = dtend.strftime("%Y%m%d") dbname = account + "_d" else: # TODO: extract strange (aka non Olson) TZs from params['TZID'] # perhaps better done in model/vevent if dtstart.tzinfo is None: dtstart = self.conf.default.default_timezone.localize(dtstart) if dtend.tzinfo is None: dtend = self.conf.default.default_timezone.localize(dtend) dtstart_utc = dtstart.astimezone(pytz.UTC) dtend_utc = dtend.astimezone(pytz.UTC) dbstart = calendar.timegm(dtstart_utc.timetuple()) dbend = calendar.timegm(dtend_utc.timetuple()) dbname = account + "_dt" sql_s = "INSERT INTO {0} (dtstart, dtend, href) VALUES (?, ?, ?);".format( dbname ) stuple = (dbstart, dbend, href) self.sql_ex(sql_s, stuple, commit=False) sql_s = ( "INSERT OR REPLACE INTO {0} " "(status, vevent, etag, href) " "VALUES (?, ?, ?, " "COALESCE((SELECT href FROM {0} WHERE href = ?), ?)" ");".format(account + "_m") ) stuple = (status, vevent.to_ical().decode("utf-8"), etag, href, href) self.sql_ex(sql_s, stuple, commit=False) self.conn.commit()
https://github.com/pimutils/khal/issues/7
Traceback (most recent call last): File "/home/catern/src/khal/virt/bin/khal", line 5, in <module> pkg_resources.run_script('khal==0.1.0.dev', 'khal') File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script self.require(requires)[0].run_script(script_name, ns) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 1462, in run_script exec_(script_code, namespace, namespace) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 41, in exec_ exec("""exec code in globs, locs""") File "<string>", line 1, in <module> File "/home/catern/src/khal/virt/lib/python2.7/site-packages/khal-0.1.0.dev-py2.7.egg/EGG-INFO/scripts/khal", line 72, in <module> File "build/bdist.linux-x86_64/egg/khal/controllers.py", line 178, in __init__ File "build/bdist.linux-x86_64/egg/khal/backend.py", line 440, in get_allday_range File "build/bdist.linux-x86_64/egg/khal/backend.py", line 164, in sql_ex sqlite3.OperationalError: no such table: simple_d
sqlite3.OperationalError
def update_href(self, oldhref, newhref, account, etag="", status=OK): """updates old_href to new_href, can also alter etag and status, see update() for an explanation of these parameters""" self._check_account(account) stuple = (newhref, etag, status, oldhref) sql_s = "UPDATE {0} SET href = ?, etag = ?, status = ? \ WHERE href = ?;".format(account + "_m") self.sql_ex(sql_s, stuple) for dbname in [account + "_d", account + "_dt"]: sql_s = "UPDATE {0} SET href = ? WHERE href = ?;".format(dbname) self.sql_ex(sql_s, (newhref, oldhref))
def update_href(self, oldhref, newhref, account, etag="", status=OK): """updates old_href to new_href, can also alter etag and status, see update() for an explanation of these parameters""" stuple = (newhref, etag, status, oldhref) sql_s = "UPDATE {0} SET href = ?, etag = ?, status = ? \ WHERE href = ?;".format(account + "_m") self.sql_ex(sql_s, stuple) for dbname in [account + "_d", account + "_dt"]: sql_s = "UPDATE {0} SET href = ? WHERE href = ?;".format(dbname) self.sql_ex(sql_s, (newhref, oldhref))
https://github.com/pimutils/khal/issues/7
Traceback (most recent call last): File "/home/catern/src/khal/virt/bin/khal", line 5, in <module> pkg_resources.run_script('khal==0.1.0.dev', 'khal') File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script self.require(requires)[0].run_script(script_name, ns) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 1462, in run_script exec_(script_code, namespace, namespace) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 41, in exec_ exec("""exec code in globs, locs""") File "<string>", line 1, in <module> File "/home/catern/src/khal/virt/lib/python2.7/site-packages/khal-0.1.0.dev-py2.7.egg/EGG-INFO/scripts/khal", line 72, in <module> File "build/bdist.linux-x86_64/egg/khal/controllers.py", line 178, in __init__ File "build/bdist.linux-x86_64/egg/khal/backend.py", line 440, in get_allday_range File "build/bdist.linux-x86_64/egg/khal/backend.py", line 164, in sql_ex sqlite3.OperationalError: no such table: simple_d
sqlite3.OperationalError
def href_exists(self, href, account): """returns True if href already exists in db :param href: href :type href: str() :returns: True or False """ self._check_account(account) sql_s = "SELECT href FROM {0} WHERE href = ?;".format(account) if len(self.sql_ex(sql_s, (href,))) == 0: return False else: return True
def href_exists(self, href, account): """returns True if href already exists in db :param href: href :type href: str() :returns: True or False """ sql_s = "SELECT href FROM {0} WHERE href = ?;".format(account) if len(self.sql_ex(sql_s, (href,))) == 0: return False else: return True
https://github.com/pimutils/khal/issues/7
Traceback (most recent call last): File "/home/catern/src/khal/virt/bin/khal", line 5, in <module> pkg_resources.run_script('khal==0.1.0.dev', 'khal') File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script self.require(requires)[0].run_script(script_name, ns) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 1462, in run_script exec_(script_code, namespace, namespace) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 41, in exec_ exec("""exec code in globs, locs""") File "<string>", line 1, in <module> File "/home/catern/src/khal/virt/lib/python2.7/site-packages/khal-0.1.0.dev-py2.7.egg/EGG-INFO/scripts/khal", line 72, in <module> File "build/bdist.linux-x86_64/egg/khal/controllers.py", line 178, in __init__ File "build/bdist.linux-x86_64/egg/khal/backend.py", line 440, in get_allday_range File "build/bdist.linux-x86_64/egg/khal/backend.py", line 164, in sql_ex sqlite3.OperationalError: no such table: simple_d
sqlite3.OperationalError
def get_etag(self, href, account): """get etag for href type href: str() return: etag rtype: str() """ self._check_account(account) sql_s = "SELECT etag FROM {0} WHERE href=(?);".format(account + "_m") etag = self.sql_ex(sql_s, (href,))[0][0] return etag
def get_etag(self, href, account): """get etag for href type href: str() return: etag rtype: str() """ sql_s = "SELECT etag FROM {0} WHERE href=(?);".format(account + "_m") etag = self.sql_ex(sql_s, (href,))[0][0] return etag
https://github.com/pimutils/khal/issues/7
Traceback (most recent call last): File "/home/catern/src/khal/virt/bin/khal", line 5, in <module> pkg_resources.run_script('khal==0.1.0.dev', 'khal') File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script self.require(requires)[0].run_script(script_name, ns) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 1462, in run_script exec_(script_code, namespace, namespace) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 41, in exec_ exec("""exec code in globs, locs""") File "<string>", line 1, in <module> File "/home/catern/src/khal/virt/lib/python2.7/site-packages/khal-0.1.0.dev-py2.7.egg/EGG-INFO/scripts/khal", line 72, in <module> File "build/bdist.linux-x86_64/egg/khal/controllers.py", line 178, in __init__ File "build/bdist.linux-x86_64/egg/khal/backend.py", line 440, in get_allday_range File "build/bdist.linux-x86_64/egg/khal/backend.py", line 164, in sql_ex sqlite3.OperationalError: no such table: simple_d
sqlite3.OperationalError
def delete(self, href, account): """ removes the event from the db, returns nothing """ self._check_account(account) logging.debug("locally deleting " + str(href)) for dbname in [account + "_d", account + "_dt", account + "_m"]: sql_s = "DELETE FROM {0} WHERE href = ? ;".format(dbname) self.sql_ex(sql_s, (href,))
def delete(self, href, account): """ removes the event from the db, returns nothing """ logging.debug("locally deleting " + str(href)) for dbname in [account + "_d", account + "_dt", account + "_m"]: sql_s = "DELETE FROM {0} WHERE href = ? ;".format(dbname) self.sql_ex(sql_s, (href,))
https://github.com/pimutils/khal/issues/7
Traceback (most recent call last): File "/home/catern/src/khal/virt/bin/khal", line 5, in <module> pkg_resources.run_script('khal==0.1.0.dev', 'khal') File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script self.require(requires)[0].run_script(script_name, ns) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 1462, in run_script exec_(script_code, namespace, namespace) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 41, in exec_ exec("""exec code in globs, locs""") File "<string>", line 1, in <module> File "/home/catern/src/khal/virt/lib/python2.7/site-packages/khal-0.1.0.dev-py2.7.egg/EGG-INFO/scripts/khal", line 72, in <module> File "build/bdist.linux-x86_64/egg/khal/controllers.py", line 178, in __init__ File "build/bdist.linux-x86_64/egg/khal/backend.py", line 440, in get_allday_range File "build/bdist.linux-x86_64/egg/khal/backend.py", line 164, in sql_ex sqlite3.OperationalError: no such table: simple_d
sqlite3.OperationalError
def get_all_href_from_db(self, accounts): """returns a list with all hrefs""" result = list() for account in accounts: self._check_account(account) hrefs = self.sql_ex("SELECT href FROM {0}".format(account + "_m")) result = result + [(href[0], account) for href in hrefs] return result
def get_all_href_from_db(self, accounts): """returns a list with all hrefs""" result = list() for account in accounts: hrefs = self.sql_ex("SELECT href FROM {0}".format(account + "_m")) result = result + [(href[0], account) for href in hrefs] return result
https://github.com/pimutils/khal/issues/7
Traceback (most recent call last): File "/home/catern/src/khal/virt/bin/khal", line 5, in <module> pkg_resources.run_script('khal==0.1.0.dev', 'khal') File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script self.require(requires)[0].run_script(script_name, ns) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 1462, in run_script exec_(script_code, namespace, namespace) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 41, in exec_ exec("""exec code in globs, locs""") File "<string>", line 1, in <module> File "/home/catern/src/khal/virt/lib/python2.7/site-packages/khal-0.1.0.dev-py2.7.egg/EGG-INFO/scripts/khal", line 72, in <module> File "build/bdist.linux-x86_64/egg/khal/controllers.py", line 178, in __init__ File "build/bdist.linux-x86_64/egg/khal/backend.py", line 440, in get_allday_range File "build/bdist.linux-x86_64/egg/khal/backend.py", line 164, in sql_ex sqlite3.OperationalError: no such table: simple_d
sqlite3.OperationalError
def get_all_href_from_db_not_new(self, accounts): """returns list of all not new hrefs""" result = list() for account in accounts: self._check_account(account) sql_s = "SELECT href FROM {0} WHERE status != (?)".format(account + "_m") stuple = (NEW,) hrefs = self.sql_ex(sql_s, stuple) result = result + [(href[0], account) for href in hrefs] return result
def get_all_href_from_db_not_new(self, accounts): """returns list of all not new hrefs""" result = list() for account in accounts: sql_s = "SELECT href FROM {0} WHERE status != (?)".format(account + "_m") stuple = (NEW,) hrefs = self.sql_ex(sql_s, stuple) result = result + [(href[0], account) for href in hrefs] return result
https://github.com/pimutils/khal/issues/7
Traceback (most recent call last): File "/home/catern/src/khal/virt/bin/khal", line 5, in <module> pkg_resources.run_script('khal==0.1.0.dev', 'khal') File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script self.require(requires)[0].run_script(script_name, ns) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 1462, in run_script exec_(script_code, namespace, namespace) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 41, in exec_ exec("""exec code in globs, locs""") File "<string>", line 1, in <module> File "/home/catern/src/khal/virt/lib/python2.7/site-packages/khal-0.1.0.dev-py2.7.egg/EGG-INFO/scripts/khal", line 72, in <module> File "build/bdist.linux-x86_64/egg/khal/controllers.py", line 178, in __init__ File "build/bdist.linux-x86_64/egg/khal/backend.py", line 440, in get_allday_range File "build/bdist.linux-x86_64/egg/khal/backend.py", line 164, in sql_ex sqlite3.OperationalError: no such table: simple_d
sqlite3.OperationalError
def get_time_range( self, start, end, account, color="", readonly=False, unicode_symbols=True, show_deleted=True, ): """returns :type start: datetime.datetime :type end: datetime.datetime :param deleted: include deleted events in returned lsit """ self._check_account(account) start = time.mktime(start.timetuple()) end = time.mktime(end.timetuple()) sql_s = ( "SELECT href, dtstart, dtend FROM {0} WHERE " "dtstart >= ? AND dtstart <= ? OR " "dtend >= ? AND dtend <= ? OR " "dtstart <= ? AND dtend >= ?" ).format(account + "_dt") stuple = (start, end, start, end, start, end) result = self.sql_ex(sql_s, stuple) event_list = list() for href, start, end in result: start = pytz.UTC.localize(datetime.datetime.utcfromtimestamp(start)) end = pytz.UTC.localize(datetime.datetime.utcfromtimestamp(end)) event = self.get_vevent_from_db( href, account, start=start, end=end, color=color, readonly=readonly, unicode_symbols=unicode_symbols, ) if show_deleted or event.status not in [DELETED, CALCHANGED, NEWDELETE]: event_list.append(event) return event_list
def get_time_range( self, start, end, account, color="", readonly=False, unicode_symbols=True, show_deleted=True, ): """returns :type start: datetime.datetime :type end: datetime.datetime :param deleted: include deleted events in returned lsit """ start = time.mktime(start.timetuple()) end = time.mktime(end.timetuple()) sql_s = ( "SELECT href, dtstart, dtend FROM {0} WHERE " "dtstart >= ? AND dtstart <= ? OR " "dtend >= ? AND dtend <= ? OR " "dtstart <= ? AND dtend >= ?" ).format(account + "_dt") stuple = (start, end, start, end, start, end) result = self.sql_ex(sql_s, stuple) event_list = list() for href, start, end in result: start = pytz.UTC.localize(datetime.datetime.utcfromtimestamp(start)) end = pytz.UTC.localize(datetime.datetime.utcfromtimestamp(end)) event = self.get_vevent_from_db( href, account, start=start, end=end, color=color, readonly=readonly, unicode_symbols=unicode_symbols, ) if show_deleted or event.status not in [DELETED, CALCHANGED, NEWDELETE]: event_list.append(event) return event_list
https://github.com/pimutils/khal/issues/7
Traceback (most recent call last): File "/home/catern/src/khal/virt/bin/khal", line 5, in <module> pkg_resources.run_script('khal==0.1.0.dev', 'khal') File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script self.require(requires)[0].run_script(script_name, ns) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 1462, in run_script exec_(script_code, namespace, namespace) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 41, in exec_ exec("""exec code in globs, locs""") File "<string>", line 1, in <module> File "/home/catern/src/khal/virt/lib/python2.7/site-packages/khal-0.1.0.dev-py2.7.egg/EGG-INFO/scripts/khal", line 72, in <module> File "build/bdist.linux-x86_64/egg/khal/controllers.py", line 178, in __init__ File "build/bdist.linux-x86_64/egg/khal/backend.py", line 440, in get_allday_range File "build/bdist.linux-x86_64/egg/khal/backend.py", line 164, in sql_ex sqlite3.OperationalError: no such table: simple_d
sqlite3.OperationalError
def get_allday_range( self, start, end=None, account=None, color="", readonly=False, unicode_symbols=True, show_deleted=True, ): self._check_account(account) if account is None: raise Exception("need to specify an account") strstart = start.strftime("%Y%m%d") if end is None: end = start + datetime.timedelta(days=1) strend = end.strftime("%Y%m%d") sql_s = ( "SELECT href, dtstart, dtend FROM {0} WHERE " "dtstart >= ? AND dtstart < ? OR " "dtend > ? AND dtend <= ? OR " "dtstart <= ? AND dtend > ? " ).format(account + "_d") stuple = (strstart, strend, strstart, strend, strstart, strend) result = self.sql_ex(sql_s, stuple) event_list = list() for href, start, end in result: start = time.strptime(str(start), "%Y%m%d") end = time.strptime(str(end), "%Y%m%d") start = datetime.date(start.tm_year, start.tm_mon, start.tm_mday) end = datetime.date(end.tm_year, end.tm_mon, end.tm_mday) vevent = self.get_vevent_from_db( href, account, start=start, end=end, color=color, readonly=readonly, unicode_symbols=unicode_symbols, ) if show_deleted or vevent.status not in [DELETED, CALCHANGED, NEWDELETE]: event_list.append(vevent) return event_list
def get_allday_range( self, start, end=None, account=None, color="", readonly=False, unicode_symbols=True, show_deleted=True, ): if account is None: raise Exception("need to specify an account") strstart = start.strftime("%Y%m%d") if end is None: end = start + datetime.timedelta(days=1) strend = end.strftime("%Y%m%d") sql_s = ( "SELECT href, dtstart, dtend FROM {0} WHERE " "dtstart >= ? AND dtstart < ? OR " "dtend > ? AND dtend <= ? OR " "dtstart <= ? AND dtend > ? " ).format(account + "_d") stuple = (strstart, strend, strstart, strend, strstart, strend) result = self.sql_ex(sql_s, stuple) event_list = list() for href, start, end in result: start = time.strptime(str(start), "%Y%m%d") end = time.strptime(str(end), "%Y%m%d") start = datetime.date(start.tm_year, start.tm_mon, start.tm_mday) end = datetime.date(end.tm_year, end.tm_mon, end.tm_mday) vevent = self.get_vevent_from_db( href, account, start=start, end=end, color=color, readonly=readonly, unicode_symbols=unicode_symbols, ) if show_deleted or vevent.status not in [DELETED, CALCHANGED, NEWDELETE]: event_list.append(vevent) return event_list
https://github.com/pimutils/khal/issues/7
Traceback (most recent call last): File "/home/catern/src/khal/virt/bin/khal", line 5, in <module> pkg_resources.run_script('khal==0.1.0.dev', 'khal') File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script self.require(requires)[0].run_script(script_name, ns) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 1462, in run_script exec_(script_code, namespace, namespace) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 41, in exec_ exec("""exec code in globs, locs""") File "<string>", line 1, in <module> File "/home/catern/src/khal/virt/lib/python2.7/site-packages/khal-0.1.0.dev-py2.7.egg/EGG-INFO/scripts/khal", line 72, in <module> File "build/bdist.linux-x86_64/egg/khal/controllers.py", line 178, in __init__ File "build/bdist.linux-x86_64/egg/khal/backend.py", line 440, in get_allday_range File "build/bdist.linux-x86_64/egg/khal/backend.py", line 164, in sql_ex sqlite3.OperationalError: no such table: simple_d
sqlite3.OperationalError
def hrefs_by_time_range_datetime(self, start, end, account, color=""): """returns :type start: datetime.datetime :type end: datetime.datetime """ self._check_account(account) start = time.mktime(start.timetuple()) end = time.mktime(end.timetuple()) sql_s = ( "SELECT href FROM {0} WHERE " "dtstart >= ? AND dtstart <= ? OR " "dtend >= ? AND dtend <= ? OR " "dtstart <= ? AND dtend >= ?" ).format(account + "_dt") stuple = (start, end, start, end, start, end) result = self.sql_ex(sql_s, stuple) return [one[0] for one in result]
def hrefs_by_time_range_datetime(self, start, end, account, color=""): """returns :type start: datetime.datetime :type end: datetime.datetime """ start = time.mktime(start.timetuple()) end = time.mktime(end.timetuple()) sql_s = ( "SELECT href FROM {0} WHERE " "dtstart >= ? AND dtstart <= ? OR " "dtend >= ? AND dtend <= ? OR " "dtstart <= ? AND dtend >= ?" ).format(account + "_dt") stuple = (start, end, start, end, start, end) result = self.sql_ex(sql_s, stuple) return [one[0] for one in result]
https://github.com/pimutils/khal/issues/7
Traceback (most recent call last): File "/home/catern/src/khal/virt/bin/khal", line 5, in <module> pkg_resources.run_script('khal==0.1.0.dev', 'khal') File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script self.require(requires)[0].run_script(script_name, ns) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 1462, in run_script exec_(script_code, namespace, namespace) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 41, in exec_ exec("""exec code in globs, locs""") File "<string>", line 1, in <module> File "/home/catern/src/khal/virt/lib/python2.7/site-packages/khal-0.1.0.dev-py2.7.egg/EGG-INFO/scripts/khal", line 72, in <module> File "build/bdist.linux-x86_64/egg/khal/controllers.py", line 178, in __init__ File "build/bdist.linux-x86_64/egg/khal/backend.py", line 440, in get_allday_range File "build/bdist.linux-x86_64/egg/khal/backend.py", line 164, in sql_ex sqlite3.OperationalError: no such table: simple_d
sqlite3.OperationalError
def hrefs_by_time_range_date(self, start, end=None, account=None): self._check_account(account) if account is None: raise Exception("need to specify an account") strstart = start.strftime("%Y%m%d") if end is None: end = start + datetime.timedelta(days=1) strend = end.strftime("%Y%m%d") sql_s = ( "SELECT href FROM {0} WHERE " "dtstart >= ? AND dtstart < ? OR " "dtend > ? AND dtend <= ? OR " "dtstart <= ? AND dtend > ? " ).format(account + "_d") stuple = (strstart, strend, strstart, strend, strstart, strend) result = self.sql_ex(sql_s, stuple) return [one[0] for one in result]
def hrefs_by_time_range_date(self, start, end=None, account=None): if account is None: raise Exception("need to specify an account") strstart = start.strftime("%Y%m%d") if end is None: end = start + datetime.timedelta(days=1) strend = end.strftime("%Y%m%d") sql_s = ( "SELECT href FROM {0} WHERE " "dtstart >= ? AND dtstart < ? OR " "dtend > ? AND dtend <= ? OR " "dtstart <= ? AND dtend > ? " ).format(account + "_d") stuple = (strstart, strend, strstart, strend, strstart, strend) result = self.sql_ex(sql_s, stuple) return [one[0] for one in result]
https://github.com/pimutils/khal/issues/7
Traceback (most recent call last): File "/home/catern/src/khal/virt/bin/khal", line 5, in <module> pkg_resources.run_script('khal==0.1.0.dev', 'khal') File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script self.require(requires)[0].run_script(script_name, ns) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 1462, in run_script exec_(script_code, namespace, namespace) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 41, in exec_ exec("""exec code in globs, locs""") File "<string>", line 1, in <module> File "/home/catern/src/khal/virt/lib/python2.7/site-packages/khal-0.1.0.dev-py2.7.egg/EGG-INFO/scripts/khal", line 72, in <module> File "build/bdist.linux-x86_64/egg/khal/controllers.py", line 178, in __init__ File "build/bdist.linux-x86_64/egg/khal/backend.py", line 440, in get_allday_range File "build/bdist.linux-x86_64/egg/khal/backend.py", line 164, in sql_ex sqlite3.OperationalError: no such table: simple_d
sqlite3.OperationalError
def get_vevent_from_db( self, href, account, start=None, end=None, readonly=False, color=lambda x: x, unicode_symbols=True, ): """returns the Event matching href, if start and end are given, a specific Event from a Recursion set is returned, the Event as saved in the db All other parameters given to this function are handed over to the Event. """ self._check_account(account) sql_s = "SELECT vevent, status, etag FROM {0} WHERE href=(?)".format(account + "_m") result = self.sql_ex(sql_s, (href,)) return Event( result[0][0], local_tz=self.conf.default.local_timezone, default_tz=self.conf.default.default_timezone, start=start, end=end, color=color, href=href, account=account, status=result[0][1], readonly=readonly, etag=result[0][2], unicode_symbols=unicode_symbols, )
def get_vevent_from_db( self, href, account, start=None, end=None, readonly=False, color=lambda x: x, unicode_symbols=True, ): """returns the Event matching href, if start and end are given, a specific Event from a Recursion set is returned, the Event as saved in the db All other parameters given to this function are handed over to the Event. """ sql_s = "SELECT vevent, status, etag FROM {0} WHERE href=(?)".format(account + "_m") result = self.sql_ex(sql_s, (href,)) return Event( result[0][0], local_tz=self.conf.default.local_timezone, default_tz=self.conf.default.default_timezone, start=start, end=end, color=color, href=href, account=account, status=result[0][1], readonly=readonly, etag=result[0][2], unicode_symbols=unicode_symbols, )
https://github.com/pimutils/khal/issues/7
Traceback (most recent call last): File "/home/catern/src/khal/virt/bin/khal", line 5, in <module> pkg_resources.run_script('khal==0.1.0.dev', 'khal') File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script self.require(requires)[0].run_script(script_name, ns) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 1462, in run_script exec_(script_code, namespace, namespace) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 41, in exec_ exec("""exec code in globs, locs""") File "<string>", line 1, in <module> File "/home/catern/src/khal/virt/lib/python2.7/site-packages/khal-0.1.0.dev-py2.7.egg/EGG-INFO/scripts/khal", line 72, in <module> File "build/bdist.linux-x86_64/egg/khal/controllers.py", line 178, in __init__ File "build/bdist.linux-x86_64/egg/khal/backend.py", line 440, in get_allday_range File "build/bdist.linux-x86_64/egg/khal/backend.py", line 164, in sql_ex sqlite3.OperationalError: no such table: simple_d
sqlite3.OperationalError
def get_changed(self, account): """returns list of hrefs of locally edited vevents""" self._check_account(account) sql_s = "SELECT href FROM {0} WHERE status == (?)".format(account + "_m") result = self.sql_ex(sql_s, (CHANGED,)) return [row[0] for row in result]
def get_changed(self, account): """returns list of hrefs of locally edited vevents""" sql_s = "SELECT href FROM {0} WHERE status == (?)".format(account + "_m") result = self.sql_ex(sql_s, (CHANGED,)) return [row[0] for row in result]
https://github.com/pimutils/khal/issues/7
Traceback (most recent call last): File "/home/catern/src/khal/virt/bin/khal", line 5, in <module> pkg_resources.run_script('khal==0.1.0.dev', 'khal') File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script self.require(requires)[0].run_script(script_name, ns) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 1462, in run_script exec_(script_code, namespace, namespace) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 41, in exec_ exec("""exec code in globs, locs""") File "<string>", line 1, in <module> File "/home/catern/src/khal/virt/lib/python2.7/site-packages/khal-0.1.0.dev-py2.7.egg/EGG-INFO/scripts/khal", line 72, in <module> File "build/bdist.linux-x86_64/egg/khal/controllers.py", line 178, in __init__ File "build/bdist.linux-x86_64/egg/khal/backend.py", line 440, in get_allday_range File "build/bdist.linux-x86_64/egg/khal/backend.py", line 164, in sql_ex sqlite3.OperationalError: no such table: simple_d
sqlite3.OperationalError
def get_new(self, account): """returns list of hrefs of locally added vcards""" self._check_account(account) sql_s = "SELECT href FROM {0} WHERE status == (?)".format(account + "_m") result = self.sql_ex(sql_s, (NEW,)) return [row[0] for row in result]
def get_new(self, account): """returns list of hrefs of locally added vcards""" sql_s = "SELECT href FROM {0} WHERE status == (?)".format(account + "_m") result = self.sql_ex(sql_s, (NEW,)) return [row[0] for row in result]
https://github.com/pimutils/khal/issues/7
Traceback (most recent call last): File "/home/catern/src/khal/virt/bin/khal", line 5, in <module> pkg_resources.run_script('khal==0.1.0.dev', 'khal') File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script self.require(requires)[0].run_script(script_name, ns) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 1462, in run_script exec_(script_code, namespace, namespace) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 41, in exec_ exec("""exec code in globs, locs""") File "<string>", line 1, in <module> File "/home/catern/src/khal/virt/lib/python2.7/site-packages/khal-0.1.0.dev-py2.7.egg/EGG-INFO/scripts/khal", line 72, in <module> File "build/bdist.linux-x86_64/egg/khal/controllers.py", line 178, in __init__ File "build/bdist.linux-x86_64/egg/khal/backend.py", line 440, in get_allday_range File "build/bdist.linux-x86_64/egg/khal/backend.py", line 164, in sql_ex sqlite3.OperationalError: no such table: simple_d
sqlite3.OperationalError
def get_marked_delete(self, account): """returns list of tuples (hrefs, etags) of locally deleted vcards""" self._check_account(account) sql_s = "SELECT href, etag FROM {0} WHERE status == (?)".format(account + "_m") result = self.sql_ex(sql_s, (DELETED,)) return result
def get_marked_delete(self, account): """returns list of tuples (hrefs, etags) of locally deleted vcards""" sql_s = "SELECT href, etag FROM {0} WHERE status == (?)".format(account + "_m") result = self.sql_ex(sql_s, (DELETED,)) return result
https://github.com/pimutils/khal/issues/7
Traceback (most recent call last): File "/home/catern/src/khal/virt/bin/khal", line 5, in <module> pkg_resources.run_script('khal==0.1.0.dev', 'khal') File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script self.require(requires)[0].run_script(script_name, ns) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 1462, in run_script exec_(script_code, namespace, namespace) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 41, in exec_ exec("""exec code in globs, locs""") File "<string>", line 1, in <module> File "/home/catern/src/khal/virt/lib/python2.7/site-packages/khal-0.1.0.dev-py2.7.egg/EGG-INFO/scripts/khal", line 72, in <module> File "build/bdist.linux-x86_64/egg/khal/controllers.py", line 178, in __init__ File "build/bdist.linux-x86_64/egg/khal/backend.py", line 440, in get_allday_range File "build/bdist.linux-x86_64/egg/khal/backend.py", line 164, in sql_ex sqlite3.OperationalError: no such table: simple_d
sqlite3.OperationalError
def mark_delete(self, href, account): """marks the entry as to be deleted on server on next sync""" self._check_account(account) sql_s = "UPDATE {0} SET STATUS = ? WHERE href = ?".format(account + "_m") self.sql_ex( sql_s, ( DELETED, href, ), )
def mark_delete(self, href, account): """marks the entry as to be deleted on server on next sync""" sql_s = "UPDATE {0} SET STATUS = ? WHERE href = ?".format(account + "_m") self.sql_ex( sql_s, ( DELETED, href, ), )
https://github.com/pimutils/khal/issues/7
Traceback (most recent call last): File "/home/catern/src/khal/virt/bin/khal", line 5, in <module> pkg_resources.run_script('khal==0.1.0.dev', 'khal') File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script self.require(requires)[0].run_script(script_name, ns) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 1462, in run_script exec_(script_code, namespace, namespace) File "/home/catern/src/khal/virt/lib/python2.7/site-packages/pkg_resources.py", line 41, in exec_ exec("""exec code in globs, locs""") File "<string>", line 1, in <module> File "/home/catern/src/khal/virt/lib/python2.7/site-packages/khal-0.1.0.dev-py2.7.egg/EGG-INFO/scripts/khal", line 72, in <module> File "build/bdist.linux-x86_64/egg/khal/controllers.py", line 178, in __init__ File "build/bdist.linux-x86_64/egg/khal/backend.py", line 440, in get_allday_range File "build/bdist.linux-x86_64/egg/khal/backend.py", line 164, in sql_ex sqlite3.OperationalError: no such table: simple_d
sqlite3.OperationalError